Highlighting a line in 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

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 7:45 pm

Hey im trying to highlight or select an unknown line, the name is in a variable, in a data grid with out using the mouse to click on it so i can get the data from it and I have looked everywhere and I can't find the code and I need some help :|

Code: Select all

 //highlight the correct line
   --   select the line thecompound in group "compound info" 
   
   --   find the lineIndex of thecompound in group "compound info"
   --   put the lineIndex of me into compoundline
   
   --   set the hilitedLine of group "compound info" to thecompound
   
   --   get lineIndex of thecompound of group "compound info"
   put thecompound into field "test 1" 
   get the lineIndex of item thecompound of group "compound info"
   //takes the highlited lines of the field and puts it into a variable
   --   put the dgHilitedLines of group "compound info" into compoundline
   //takes the data of that line and splits it into the right columns 
   put the dgDataOfLine[compoundLine] of group "compound info" into compoundData
Last edited by macman56 on Tue Aug 27, 2013 8:39 pm, edited 3 times in total.

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

Re: Highlighting a line in a data grid

Post by Simon » Tue Aug 27, 2013 8:06 pm

Hi macman56,
Welcome to the forum :)

This is a data grid form correct?
In the DG group add:

Code: Select all

on mouseDoubleUp
   put the dgHilitedIndex of me into theIndex
   put GetDataOfIndex (theIndex,first_name) into fld "firstname"
   put GetDataOfIndex (theIndex,last_name) into fld "lastname"
end mouseDoubleUp
first_name/last_name you will have to change there to match your keys. Oh, and where you want to put them.

And If I misunderstood your question entirely... Drats!

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

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 8:13 pm

Thx but thats not what im what im looking for

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

Re: Highlighting a line in a data grid

Post by Simon » Tue Aug 27, 2013 8:28 pm

Ooops sorry.. "no mouse"

Code: Select all

 set the dgHilitedIndex of group "compound info" to 2
and then the rest of the "GetDataOfIndex "

Is that right?

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

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 8:39 pm

thx but no its still not working

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

Re: Highlighting a line in a data grid

Post by Simon » Tue Aug 27, 2013 8:43 pm

I guess then if you want help you could add a bit more than "thx but no its still not working".
Which part isn't working?
What isn't it doing for you?
Could you explain in more detail what you are after?

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

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 8:50 pm

im trying to take my global variable that contains the row im looking for, thecompound, and find and highlight it in my data grind, group "compound info", without using my mouse

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

Re: Highlighting a line in a data grid

Post by Simon » Tue Aug 27, 2013 8:55 pm

Interesting, because that's what it's doing here:
set the dgHilitedIndex of group "compound info" to thecompound
Doesn't highlight thecompound row for you?

Does it highlight any row for you?

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

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 9:01 pm

No its not highlighting any row

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

Re: Highlighting a line in a data grid

Post by Simon » Tue Aug 27, 2013 9:08 pm

Is thecompound within the range of keys you have? If it's higher than the number of keys nothing will be highlighted.

Try setting the thecompound to 1, you must have at least 1 key in the DG or did your array start on a different number?
Hey maybe you didn't use numeric's in your array? Can you post part of the array you used to fill the DG?

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

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 9:12 pm

thecompound is a word and im trying to highlight the word in the data grid. The following is the coloumn im tryng to highlight in:

H2O1
C1O2
N1O2
C1H2O1

and im trying to highlight: H2O1

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

Re: Highlighting a line in a data grid

Post by Simon » Tue Aug 27, 2013 9:35 pm

oops:
This is a data grid form correct?
Anyways, try the attached stack and tell me what it's not doing correctly for you.

Simon
Attachments
DG_Highlight.zip
LC 6.0
(4.31 KiB) Downloaded 343 times
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 9:39 pm

I want to do the highlight button but in the stack script without using the the button

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

Re: Highlighting a line in a data grid

Post by Simon » Tue Aug 27, 2013 9:50 pm

Ah, so the button did work for you!
If you look into the script of the button it notes that the line did not have to be in a button. Put the anywhere that's available to the DG.

So the problem you are facing is the script works it's just not working from where you are running it? Which then asks how do you trigger it or exactly how do you want it to be triggered? e.g openCard, after the DG is loaded, when someone types something into a field???

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

macman56
Posts: 17
Joined: Tue Aug 27, 2013 7:31 pm

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 9:54 pm

On cCompoundInfo

Post Reply