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

Re: Highlighting a line in a data grid

Post by macman56 » Tue Aug 27, 2013 10:00 pm

there is no code in 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 10:04 pm

Then:
On cCompoundInfo
set the dgHilitedIndex of group "compound info" to 1

Stick to using 1 until this gets sorted

Now you may need to add the card:
set the dgHilitedIndex of group "compound info" of cd "myCD"to 1

But you should use a button on the card with the DG just to prove it works then move the code to your On cCompoundInfo (which you have been sufficiently cryptic about where it is).

The best thing to do is post your stack here because there can be a million bits of code that prevent this from working.

But we have proved that "set the dgHilitedIndex of group..." does work, just where you placed it, it doesn't.

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 10:13 pm

here is the code i have for the cCompoundInfo:

Code: Select all

global thecompound
on preOpenstack
   put empty into thecompound
end preOpenstack

on cCompoundinfo
   //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"
set the dgHilitedIndex of group "compound info" to 1
//get the line
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
   //then it take the data from the right column and puts it into the appropriate field
   put compoundData["real name"] into field "name box"
   put compoundData["hybrid"] into field "hybrid box"
   put compoundData["geo"] into field "geo box"
   put compoundData["pol"] into field "pole box"
   put compoundData["rez"] into field "rez box"
end cCompoundinfo

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 10:31 pm

Ok now were getting somewhere!

Please see attached stack.
This shows that with everything clear the code does work.

Now what is preventing your stack from working I cannot solve without the entire stack. There are just too many unknowns.

I hope from this stack you can glean a path to solving your problem or you can post your whole stack.

Simon
Attachments
DG_Highlight_v2.zip
LC 6.0
(4.7 KiB) Downloaded 225 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 11:45 pm

ok none of the code you sent me is there but here is my entire stack:

Code: Select all

global thecompound
on preOpenstack
   put empty into thecompound
end preOpenstack

on cCompoundinfo
   //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"

set the dgHilitedIndex of group "compound info" to 1
//get the data of the line
   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
   //then it take the data from the right column and puts it into the appropriate field
   put compoundData["real name"] into field "name box"
   put compoundData["hybrid"] into field "hybrid box"
   put compoundData["geo"] into field "geo box"
   put compoundData["pol"] into field "pole box"
   put compoundData["rez"] into field "rez box"
end cCompoundinfo
on cBuildcompound
select line thecompound of group "compound builder" 
   //takes the highlited lines of the field and puts it into a variable
   put the dgHilitedLines of group "compound builder" into buildLine
   //takes the data of that line and splits it into the right columns 
   put the dgDataOfLine[buildLine] of group "compound builder" into buildData
   //puts the info into the right location
   put buildData["center"] into field "box 5"
   if buildData["box 1 element"] is empty
   then hide field "box 1"
   else
      put buildData["box 1 element"] into field "box 1"
   end if
   if buildData["box 2 element"] is empty
   then hide field "box 2"
   else
      put buildData["box 2 element"] into field "box 2"
   end if
   if buildData["box 3 element"] is empty
   then hide field "box 3"
   else
      put buildData["box 3 element"] into field "box 3"
   end if
   if buildData["box 4 element"] is empty
   then hide field "box 4"
   else
      put buildData["box 4 element"] into field "box 4"
   end if
   if buildData["box 6 element"] is empty
   then hide field "box 6"
   else
      put buildData["box 6 element"] into field "box 6"
   end if
   if buildData["box 7 element"] is empty
   then hide field "box 7"
   else
      put buildData["box 7 element"] into field "box 7"
   end if
   if buildData["box 8 element"] is empty
   then hide field "box 8"
   else
      put buildData["box 8 element"] into field "box 8"
   end if
   if buildData["box 9 element"] is empty
   then hide field "box 9"
   else
      put buildData["box 9 element"] into field "box 9"
   end if
   if buildData["bond 1"] is empty
   then hide field "bond 1"
   else
      put buildData["bond 1"] into field "bond 1"
   end if
   if buildData["bond 2"] is empty
   then hide field "bond 2"
   else
      put buildData["bond 2"] into field "bond 2"
   end if
   if buildData["bond 3"] is empty
   then hide field "bond 3"
   else
      put buildData["bond 3"] into field "bond 3"
   end if
   if buildData["bond 4"] is empty
   then hide field "bond 4"
   else
      put buildData["bond 4"] into field "bond 4"
   end if
   if buildData["bond 5"] is empty
   then hide field "bond 5"
   else
      put buildData["bond 5"] into field "bond 5"
   end if
   if buildData["bond 6"] is empty
   then hide field "bond 6"
   else
      put buildData["bond 6"] into field "bond 6"
   end if
   if buildData["bond 7"] is empty
   then hide field "bond 7"
   else
      put buildData["bond 7"] into field "bond 7"
   end if
   if buildData["bond 8"] is empty
   then hide field "bond 8"
   else
      put buildData["bond 8"] into field "bond 8"
   end if
end cBuildcompound
on cBuildrezcompound
   //check for the compound and highlight the line
select line thecompound of group "compound builder" 
   //takes the highlited lines of the field and puts it into a variable
   put the dgHilitedLines of group "compound builder" into buildrezLine
   //takes the data of that line and splits it into the right columns 
   put the dgDataOfLine[buildrezLine] of group "compound builder" into buildrezData
   //puts the info into the right location
   put buildrezData["rez center"] into field "rez box 5"
   if buildrezData["rez box 1 element"] is empty
   then hide field "rez box 1"
   else
      put buildData["rez box 1 element"] into field "rez box 1"
   end if
  if buildrezData["rez box 2 element"] is empty
   then hide field "rez box 2"
   else
      put buildData["rez box 2 element"] into field "rez box 2"
   end if
  if buildrezData["rez box 3 element"] is empty
   then hide field "rez box 3"
   else
      put buildData["rez box 3 element"] into field "rez box 3"
   end if
  if buildrezData["rez box 4 element"] is empty
   then hide field "rez box 4"
   else
      put buildData["rez box 4 element"] into field "rez box 4"
   end if
  if buildrezData["rez box 6 element"] is empty
   then hide field "rez box 6"
   else
      put buildData["rez box 6 element"] into field "rez box 6"
   end if
  if buildrezData["rez box 7 element"] is empty
   then hide field "rez box 7"
   else
      put buildData["rez box 7 element"] into field "rez box 7"
   end if
  if buildrezData["rez box 8 element"] is empty
   then hide field "rez box 8"
   else
      put buildData["rez box 8 element"] into field "rez box 8"
   end if
  if buildrezData["rez box 9 element"] is empty
   then hide field "rez box 9"
   else
      put buildData["rez box 9 element"] into field "rez box 9"
   end if
   if buildData["rez bond 1"] is empty
   then hide field "rez bond 1"
   else
      put buildData["rez bond 1"] into field "rez bond 1"
   end if
     if buildData["rez bond 2"] is empty
   then hide field "rez bond 2"
   else
      put buildData["rez bond 2"] into field "rez bond 2"
   end if
     if buildData["rez bond 3"] is empty
   then hide field "rez bond 3"
   else
      put buildData["rez bond 3"] into field "rez bond 3"
   end if
     if buildData["rez bond 4"] is empty
   then hide field "rez bond 4"
   else
      put buildData["rez bond 4"] into field "rez bond 4"
   end if
     if buildData["rez bond 5"] is empty
   then hide field "rez bond 5"
   else
      put buildData["rez bond 5"] into field "rez bond 5"
   end if
     if buildData["rez bond 6"] is empty
   then hide field "rez bond 6"
   else
      put buildData["rez bond 6"] into field "rez bond 6"
   end if
     if buildData["rez bond 7"] is empty
   then hide field "rez bond 7"
   else
      put buildData["rez bond 7"] into field "rez bond 7"
   end if
     if buildData["rez bond 8"] is empty
   then hide field "rez bond 8"
   else
      put buildData["rez bond 8"] into field "rez bond 8"
   end if
end cBuildrezcompound

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 11:56 pm

ok none of the code you sent me is there
I don't know what you are referring to?

I meant zip your LC stack up and post it here... not just the code.

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 » Wed Aug 28, 2013 4:12 pm

well simon im srry but i cant due that due to the nature of what im working on

Post Reply