Datagrid Get Column Value

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
blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Datagrid Get Column Value

Post by blairetabay » Wed Feb 26, 2014 2:41 am

hi to all,

i have a serious problem regarding with the datagrid.
i need to the values inside my datagrid per column in an array form i have a sample code but it returns it just give me the row name not the row value

datagrid name is dgGrid
recNum is the row name in my datagrid

Code: Select all

put the getDataOfIndex of the group "dgGrid" into tDataRow
   put tDataRow, "recNum " into valueFromrecNum
    answer valueFromrecNum
thank you in advance

blaireTabay

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Datagrid Get Column Value

Post by Simon » Wed Feb 26, 2014 5:19 am

Just to show I'm not really crazy;

Code: Select all

on mouseUp
   put the dgData of group "dgGrid" into theDataA
   put the dgIndexes of group "dgGrid" into theIndexes
   
   repeat for each item theIndex in theIndexes
      put theDataA[theIndex]["recNum"] & cr after tRecords
   end repeat
breakpoint
end mouseUp
Figured that out from here;
http://lessons.runrev.com/s/lessons/m/d ... -data-grid

Simon
Edit; OK from your previous post this can you figure out how to put the data into a field on another card/stack and print it?
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Re: Datagrid Get Column Value

Post by blairetabay » Wed Feb 26, 2014 7:24 am

Simon


Thank you it really help me

although it loop the entire row now i want it to show the message in just one click. in your example it will loop every column. Here is my code am I doing the right thing in showing the message?

Code: Select all


   put the dgData of group "dgGrid" into theDataA
   put the dgIndexes of group "dgGrid" into theIndexes

repeat for each item theIndex in theIndexes
      
      put "PatientName" & cr after tRecords  
      put theDataA[theIndex]["recNum"] & cr after tRecords  
    
     
     # answer tRecords
      
   end repeat

  # answer tRecords
breakpoint  
  # answer tRecords

the result is still the same i put the answer out the repeat but still looping do you have any suggestion for this? what should i do?



blaireTabay

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Datagrid Get Column Value

Post by Simon » Wed Feb 26, 2014 8:14 am

Hi blaireTabay,
I'm glad that helped you.

Again I am sorry, I do not understand your request.
I take it English is not your native language.

Have you done the DataGrid lessons here?
http://lessons.runrev.com/m/datagrid


Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Datagrid Get Column Value

Post by bangkok » Wed Feb 26, 2014 8:39 am

Code: Select all

on mouseUP

put the dgHilitedLines of me into theLine
   
answer GetDataOfLine(theLine, "PatientName")&" "&GetDataOfLine(theLine, "recNum")

end mouseUP

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

Re: Datagrid Get Column Value

Post by Klaus » Wed Feb 26, 2014 2:08 pm

Hi Blaire,

datagrids wortk with ARRAYS most of the time and also here with "dgDataOfIndex",
so you need to use the ARRAY syntax to address the contents of an array.

I think this is what you are after:
## Since I do not know WHAT row exactlyyou want to address, I use the currently hilited line
## of the datagrid as the desired row.
...
put the dgHilitedIndex of grp "dgGrid" into tCurrentRow
put the dgDataOfIndex[tCurrentRow] of group "dgGrid" into tData

## tData now contains an ARRAY, so use the array syntay (the one with []) to get the KEY you want:
put tData["recNum"] into valueFromrecNum
answer valueFromrecNum
...

Best

Klaus

Post Reply