Finding the Index of a DataGrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Finding the Index of a DataGrid
Hello, simple question:
How can I find the index that a ComboBox Menu belongs to within a DataGrid Form? (**I am writing this script in the ComboBox Menu's script, not the DG Behavior Script**)
I have checked out the recommendations for this listed on the LiveCode Lessons and Tutorials, and am getting no results from:
"put the dgIndex of me into tVar"
"put the dgIndex of the dgControl of me into tVar"
"put the dgIndex of group "DataGrid 1" of me into tVar"
"put the dgLine of me into tVar"
"put the dgLine of the dgControl of me into tVar"
"put the dgLine of group "DataGrid 1" of me into tVar"
The following DOES work when auto-hilite is true.... but I am using a DG that has the auto-hilite set to False, and want to keep it this way. SO it no longer works.
"put the dgHilitedLines of group "DataGrid 1" of me into tVar"
I assume it should be really easy, I just can't find the exact script that will return the value associated with the index that my ComboBox Menu is in.
Thanks in advance for the help!
Phil E.
How can I find the index that a ComboBox Menu belongs to within a DataGrid Form? (**I am writing this script in the ComboBox Menu's script, not the DG Behavior Script**)
I have checked out the recommendations for this listed on the LiveCode Lessons and Tutorials, and am getting no results from:
"put the dgIndex of me into tVar"
"put the dgIndex of the dgControl of me into tVar"
"put the dgIndex of group "DataGrid 1" of me into tVar"
"put the dgLine of me into tVar"
"put the dgLine of the dgControl of me into tVar"
"put the dgLine of group "DataGrid 1" of me into tVar"
The following DOES work when auto-hilite is true.... but I am using a DG that has the auto-hilite set to False, and want to keep it this way. SO it no longer works.
"put the dgHilitedLines of group "DataGrid 1" of me into tVar"
I assume it should be really easy, I just can't find the exact script that will return the value associated with the index that my ComboBox Menu is in.
Thanks in advance for the help!
Phil E.
Re: Finding the Index of a DataGrid
Hi Phil,
I'd like to help but you didn't respond to my last posting to a question of yours... Do I have your request all wrong?
Simon
I'd like to help but you didn't respond to my last posting to a question of yours... Do I have your request all wrong?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Finding the Index of a DataGrid
Indeed, sorry about the initial non-response! Thank you for reminding me.
I have chased the rabbit down the hole, and, now that I can see the script running, I can debug. I discovered that the script I am using in my actual app (not the simple test app I attached to the other thread) has some script that is not behaving how I think it ought.
That is why I started this Post; I just need to figure out how to get the dgIndex/dgLine (I don't know the difference) of the particular instance of the ComboBox that is being clicked, since there are multiple rows in my DG Form that render the same ComboBox.
Hope that makes sense, and thanks again for reminding me to respond. I really appreciate your help and attention!
Cheers,
Phil E.
I have chased the rabbit down the hole, and, now that I can see the script running, I can debug. I discovered that the script I am using in my actual app (not the simple test app I attached to the other thread) has some script that is not behaving how I think it ought.
That is why I started this Post; I just need to figure out how to get the dgIndex/dgLine (I don't know the difference) of the particular instance of the ComboBox that is being clicked, since there are multiple rows in my DG Form that render the same ComboBox.
Hope that makes sense, and thanks again for reminding me to respond. I really appreciate your help and attention!
Cheers,
Phil E.
Re: Finding the Index of a DataGrid
Hi Phil,
Thanks for your feedback.
I will look into what you have asked in the morning, sorry very tired now.
Simon
Thanks for your feedback.

I will look into what you have asked in the morning, sorry very tired now.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Finding the Index of a DataGrid
Simon,
My pleasure; get yourself some rest! I need some as well.
Good Night,
Phil E.
My pleasure; get yourself some rest! I need some as well.
Good Night,
Phil E.
Re: Finding the Index of a DataGrid
Hi Phil,
I've been messing around with this and found this in the row behavior script:
That seems to be working but I'm not sure it's what you wanted. If not just say.
Simon
I've been messing around with this and found this in the row behavior script:
Code: Select all
setprop dgHilite pBoolean
-- This custom property is set when the highlight of your custom template has
-- changed. By default the "Background" graphic will be highlighted for you.
-- You only add script here if you want to further customize the highlight.
-- Example:
if pBoolean then
put the dgLine of me
--set the foregroundColor of me to the dgProp["hilited text color"] of the dgControl of me
else
--set the foregroundColor of me to empty
end if
end dgHilite
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Finding the Index of a DataGrid
Simon,
Not sure what you are suggesting here. I manually turned the autoHilite prop off, so that my DG will NOT hilite when I click something in one of its rows.
This is in accordance with how I want it. However, by turning off the autoHilite property, the dgHilitedLines property does not allow my desired script to function.
Like I said, the only way I have been able to return the row of the DG that my clicked control is in is by keeping autoHilite ON, and using "put the dgHilitedLines of me into tVar"
...but this means I need autoHilite ON, which I don't want.
Hope that is more clear.
Cheers,
Phil E.
Not sure what you are suggesting here. I manually turned the autoHilite prop off, so that my DG will NOT hilite when I click something in one of its rows.
This is in accordance with how I want it. However, by turning off the autoHilite property, the dgHilitedLines property does not allow my desired script to function.
Like I said, the only way I have been able to return the row of the DG that my clicked control is in is by keeping autoHilite ON, and using "put the dgHilitedLines of me into tVar"
...but this means I need autoHilite ON, which I don't want.
Hope that is more clear.
Cheers,
Phil E.
Re: Finding the Index of a DataGrid
My thought was to use the auto-hilite but set it's color:
set the dgProp["hilite color"] of grp "DataGrid 1" to "white"
With that I think you can start using:
"put the dgHilitedLines of group "DataGrid 1" of me into tVar"
or at least use the above script.
Simon
set the dgProp["hilite color"] of grp "DataGrid 1" to "white"
With that I think you can start using:
"put the dgHilitedLines of group "DataGrid 1" of me into tVar"
or at least use the above script.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Finding the Index of a DataGrid
OK, I understand now, thanks.
I will give that a whirl.
So, there is no way to, say, put "the dgIndex of me into tVar" or something like that, that is not so backdoor-ish?
Just want to double check that I haven't been messing up a simpler command that is built just for this purpose.
Best,
Phil E.
I will give that a whirl.
So, there is no way to, say, put "the dgIndex of me into tVar" or something like that, that is not so backdoor-ish?
Just want to double check that I haven't been messing up a simpler command that is built just for this purpose.
Best,
Phil E.
Re: Finding the Index of a DataGrid
Simon,
That is fairly effective, fortunately. It still "hilites" the rows, but you can only tell on every other row, because of alternating row colors. However, in my actual application, I have this property set to false already, anyway, so I think it will work.
Still scratching my head that there is not some way to just get the engine to tell me which row of the DG I am clicking in.
Thank you for your innovative thinking! Let me know if a more direct approach ever comes to your attention.
Phil E.
That is fairly effective, fortunately. It still "hilites" the rows, but you can only tell on every other row, because of alternating row colors. However, in my actual application, I have this property set to false already, anyway, so I think it will work.
Still scratching my head that there is not some way to just get the engine to tell me which row of the DG I am clicking in.
Thank you for your innovative thinking! Let me know if a more direct approach ever comes to your attention.
Phil E.
Re: Finding the Index of a DataGrid
There probably is a way.
I just was thinking about being able to use the dgHilited stuff.
Simon
I just was thinking about being able to use the dgHilited stuff.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Finding the Index of a DataGrid
Ah, OK. Any idea how I would go about finding such a way? I have run into this before, and I can imagine it would just be a really handy tool to have available.
Regardless, thanks a ton for your focus and assistance! Immensely helpful.
Best,
Phil E.
Regardless, thanks a ton for your focus and assistance! Immensely helpful.
Best,
Phil E.