datagrid: No refresh the data after assign data - SOLVED

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

datagrid: No refresh the data after assign data - SOLVED

Post by JosepM » Tue May 24, 2011 9:41 pm

Hi all,

I'm in trouble with the datagrid when assign data from an array.
It's a strange behavior, so after convert the XML to array and assign it to the datagrid, the datagrid only show the visibles rows and no vertical scrollbars appear. If I check the contents of the datagrid all the data appear but isn't scrollable...

What is wrong?
ANSWER: I must replace "myxml" for my own xml tag... :roll:


I have this code from the Trevors XML to Array stack:

on mouseUp
put the text of field 1 into theXML
replace cr with empty in theXML

-- Convert xml to array. Store data in array as UTF8.
put ConvertXMLToArray(theXML, "UTF-8") into theArray -- handler in RevOnline stack

-- Convert to an array that can be assigned to the dgData of a Data Grid (numerically indexed).
put SortArrayKeysWithXMLOrdering(theArray["myxml"]) into theKeys -- handler in RevOnline stack
put 0 into i
repeat for each line theKey in theKeys
add 1 to i
put theArray["myxml"][theKey] into theData
end repeat

-- Assign to datagrid
lock screen
set the dgData of group "dg1" to theArray[entries]
unlock screen
end mouseUp

The XML looks like... they have 400 records...

<entries>
<entry>
<CLI_ID>422</CLI_ID>
<CLI_Nombre>Son Japan</CLI_Nombre>
<CLI_NIF>3455567Y</CLI_NIF>
</entry>
<entry>
<CLI_ID>68</CLI_ID>
<CLI_Nombre>Son Kiev</CLI_Nombre>
<CLI_NIF>8081344R</CLI_NIF>
</entry>
</entries>


Salut,
Josep

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: datagrid: No refresh the data after assign data - SOLVED

Post by BarrySumpter » Mon May 30, 2011 8:18 am

Code: Select all

on mouseUp
put the text of field 1 into theXML
replace cr with empty in theXML

-- Convert xml to array. Store data in array as UTF8.
put ConvertXMLToArray(theXML, "UTF-8") into theArray -- handler in RevOnline stack

-- Convert to an array that can be assigned to the dgData of a Data Grid (numerically indexed).
put SortArrayKeysWithXMLOrdering(theArray["myxml"]) into theKeys -- handler in RevOnline stack
put 0 into i
repeat for each line theKey in theKeys
    add 1 to i
    put theArray["myxml"][theKey] into theData[i]
end repeat

-- Assign to datagrid
lock screen
set the dgData of group "dg1" to theArray[entries]
unlock screen
end mouseUp
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: datagrid: No refresh the data after assign data - SOLVED

Post by Klaus » Mon May 30, 2011 12:59 pm

Hi Barry,

short question:
in your script you use a repeat loop to fill the array "theData" with data but you
do not use this array after that? Any reason for this?


Best

Klaus

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: datagrid: No refresh the data after assign data - SOLVED

Post by BarrySumpter » Mon May 30, 2011 9:48 pm

Hi Klaus,

theData is the XMLTree
theArray is an arary the dgData is expecting.



But thats NOT my work.

I can NOT get this to work.

I just placed the Code tags around the previously posted code and re-posted so I could read it better.

I had been looking thru User Samples | RevOnline | XMLAndArrays.
Trying to get an XML file generated by BigPond into a DataGrid.

http://forums.runrev.com/phpBB2/viewtop ... =49&t=7152
Someone here had posted a one line untested solution to the getting the data from the XMLAndArrays into the DataGrid:

Code: Select all

set the dgData of group "dg1" to theArray[entries]
I could NOT get this to work until I changed my DataGrid back to a table instead of a form.
NOR could I get this to work until I changed the code to this:

Code: Select all

lock screen
set the dgData of group "dg1" to theArray[entries]
unlock screen 
It finally worked with the exact xml contents from the example.
<myxml><node>value 1</node><node>value 2</node><node>value 3</node></myxml>


NO OTHER XML content would work.

But, now that I am trying to post the competed project I CAN'T get this to work again.

----

I find XML the be the absolutely biggest waste of time and effort for something that was supposed to be so efficient.
So many people have wasted so many hours writting routines to encrypte and decrypte XML.
I consider XML a scam.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: datagrid: No refresh the data after assign data - SOLVED

Post by BarrySumpter » Wed Jun 15, 2011 4:19 am

the column names must match the array key names.

So it really doesn't work well with more than a couple of unique column names/XML tree nodes.

It needs some generic code to extract the key names from the array and assign those to column names.

What the routines should be doing is basing the array/tree on the node LEVEL not the node NAME.
Where the node name is just another detail of the array dimention.

strange the data looks like its actuall there but not displaying.

Message Box:
dispatch "PrintKeys" to group "DataGrid"

Code: Select all

 -- Convert xml to array. Store data in array as UTF8.
   put ConvertXMLToArray(theXML, "UTF-8") into theArray -- handler in RevOnline stack
   
   -- Convert to an array that can be assigned to the dgData of a Data Grid (numerically indexed).
   put SortArrayKeysWithXMLOrdering(theArray["myxml"]) into theKeys -- handler in RevOnline stack
   put 0 into i
   repeat for each line theKey in theKeys
          add 1 to i
          put theArray["myxml"][theKey] into theData[i]
   end repeat
   
   lock screen
   set the dgData of group "DataGrid" to arrayEncode(theArray) --[entries]  --still not freakin workin
   unlock screen    

set the dgData of group "DataGrid" to theArray[entries] 
-- wrong don't know where the entries word came from

should be:
-- The datagrid column names must be preset befoe assigning dgData
-- I don't know how to do this generically when the xml tags could change hourly

--columns
-- Line delimited list of columns in your table.  -- this works with the Return delimiter
--    put "Col1" & Return & "Col21" & Return & "Col3" into tColumnTitles 
      set the dgProp["columns"] of group "dg1" to tColumnTitles - this works for 3 column headers

-- then the data assigned - the array key must match the column names or won't populate
    set the dgData of group "dg1" to theData
----------------
So I've pretty much given up on the XML to dataGrid for this project

Now that I think about it I want my grid to look like the Array in the Variable debuggin display:
Anyone know how to do this like this pic shows? i.e. NO column names?
- found
- link in next post -
Attachments
XML Array.gif
XML Array.gif (10.06 KiB) Viewed 4592 times
Last edited by BarrySumpter on Wed Jun 15, 2011 10:53 am, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: datagrid: No refresh the data after assign data - SOLVED

Post by BarrySumpter » Wed Jun 15, 2011 9:25 am

21022-How-do-I-Display-an-Array-in-Human-Readable-Form-
http://lessons.runrev.com/spaces/lesson ... able-Form-

its woking
but the silly ConvertXMLtoArray is forcing the nodes to sort instead of just converting as is to an array.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Post Reply