Loop through textboxes inside datagrid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
slowdash
Posts: 24
Joined: Wed Feb 22, 2012 10:52 am

Loop through textboxes inside datagrid

Post by slowdash » Wed Jul 04, 2012 7:30 am

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9742
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Loop through textboxes inside datagrid

Post by dunbarx » Wed Jul 04, 2012 7:16 pm

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

slowdash
Posts: 24
Joined: Wed Feb 22, 2012 10:52 am

Re: Loop through textboxes inside datagrid

Post by slowdash » Thu Jul 05, 2012 1:05 am

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

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am
Location: Warszawa / Poland

Re: Loop through textboxes inside datagrid

Post by snm » Thu Jul 05, 2012 6:18 am

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”