Page 1 of 1

Loop through textboxes inside datagrid

Posted: Wed Jul 04, 2012 7:30 am
by slowdash
I have a datagrid form that contains a list wherein a user can enter an amount for quantity for each row, i then have a button to let the user save the quantity, for these
i have this code

Code: Select all

 repeat with theLineNo = 1 to the dgNumberOfLines of group "myDgHere"
  put the dgDataControlOfLine[theLineNo] of group "myDgHere" into theControl
  
  if fld "quantity" of theControl is not empty then
   do something meaningful here...
  end if

 end repeat
what i notice though is that my loop only returns a "theControl" object on the datagrid's visible lines, all the other rows doesnt return objects

ex: if the height of my datagrid allows it to show 4 data, the theControl var only returns 4 objects, all controls/rows after that is empty.

Have anyone encountered a similar scenario? and can anyone please let me know in case you have other methods to loop through a datagrid that contains text fields

thanks in advanced,
-Rye

Re: Loop through textboxes inside datagrid

Posted: Wed Jul 04, 2012 7:16 pm
by dunbarx
I am no expert on datagrids, but are you sure you are using the "form" style of dataGrids? The "table" style is not compatible with this function.

I get a value for any line I click, above or below any lines with value.

I wonder if the line: " if fld "quantity" of theControl is not empty then"

requires a "do" construction to work. It feels like it. Do you know how to work these?

Craig Newman

Re: Loop through textboxes inside datagrid

Posted: Thu Jul 05, 2012 1:05 am
by slowdash
hi dunbarx, thanks for replying, sorry for leaving that out, yeah, im using the form style on my datagrid

and yeah even though im quite new to livecode, i can probably say i know a little bit about loops, as ive said, i definitely think i am missing something here regarding the retrieval of data inside the text fields in the datagrid (or this behavior of the datagrid is quite odd for me), because even though i entered/input data in the textboxes inside the grid, once the row is out of view, when i run my function to loop through the datagrid rows using the dgNumberOfLines and dgDataControlOfLine, it only returns the objects for the visible rows, all rows that is hidden from view doesnt return anything

Re: Loop through textboxes inside datagrid

Posted: Thu Jul 05, 2012 6:18 am
by snm
I'm not sure if I understand your problem well, but you can check dgData[lineNumber]["quantity"] to check if is not empty and do your stuff. dgData is array containing all DataGrid data of visible and not visible rows.

Marek