Putting info from a text field into a data grid

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
wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Putting info from a text field into a data grid

Post by wolfkillshepard » Mon Jul 18, 2011 11:35 pm

I am making an app in which the user must be able to click a button and at the click of that button text will be taken from an adjacent field (which the user types info into) and that same text would then be pasted into a data grid.

The reason I want a data grid is because the user needs to be able to select the individual line of text which will be organized by name. There will be a field that the user types the desired name of his/her "production" and when the add production button is hit, the information typed into field 1 will then be place into a datagrid. From that datagrid I need those individual "productions" to be selectable. The reason I need them selectable is because on selection of one of those "productions" I want the user to be brought into a details page. I'll provide a screenshot of the card.
Attachments
scrn.PNG

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Putting info from a text field into a data grid

Post by dunbarx » Mon Jul 18, 2011 11:51 pm

Hi.

DataGrids are composite structures made from LC objects. Check out:

http://lessons.runrev.com/spaces/lesson ... With-Data-

I don't use them much, but I have played around with the "dgText" and the "dgData"

Craig Newman

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Re: Putting info from a text field into a data grid

Post by wolfkillshepard » Tue Jul 19, 2011 12:09 am

Going through that tutorial I am still having trouble achieving my goal

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Putting info from a text field into a data grid

Post by dunbarx » Tue Jul 19, 2011 4:07 am

The datagrid contents can be thought of as an array of data. This can be manipulated as an actual LiveCode array. But, as in a spreadsheet, it can also be seen as a tab delimited field/return delimited record "array", similar to that of a spreadsheet.

We will make a datagrid, populate it, and get the "dgText", you will extract data in the above format.

Then we will change one of the items in one of the lines of your variable. This means that you have to have the itemdelimiter set to "tab". The line delimiter is already set as "return".

Make two buttons and a datagrid (named "datagrid 1"). Set three columns into your datagrid from the property inspector. In the script of the first button, put

Code: Select all

on mouseUp
   put "a" & tab & "b" & tab & "c" & return & "d" & tab & "e" & tab & "f" into var
   set the dgtext of group "datagrid 1" to var
end mouseUp
in the second button, put

Code: Select all

on mouseUp
   get the dgtext of group "datagrid 1"
   set the itemdel to tab
   put random(99) into item 2 of it
   set the dgtext of group "datagrid 1" to it
end mouseUp
Hit the first button. A little data appears in the grid. Now hit the second a few times. See how the data in the first row of the second column changes? Step through the script line by line. Call back if you need more help getting started.

Craig Newman

Post Reply