Get content of DataGrid row with mouse double-click
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Get content of DataGrid row with mouse double-click
Hi Everybody
Is it impossible to get content of row from a DataGrid table with mouse double-click?
(It's mean while weare double clicking the row)
And is it impossible too to change of highlighted color?
Comment and help would be appreciate
Best Regards
Gilar Kadarsah
Is it impossible to get content of row from a DataGrid table with mouse double-click?
(It's mean while weare double clicking the row)
And is it impossible too to change of highlighted color?
Comment and help would be appreciate
Best Regards
Gilar Kadarsah
Gilar | from INDONESIA
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: Get content of DataGrid row with mouse double-click
Here is a function for getting the info of whatever row is selected on a dataGrid that has a list of clients. The function uses that info to fill out a form with various fields:
You can then use that function however you want, for example, on the dataGrid, edit the script like:
Code: Select all
/*********************************************************
select function --selecting a client from the datagrid
**********************************************************/
on selectClient
--get the number of the highlited row
put the dgHilitedLines of grp "data" into tLine
--get the data of that line into an array
put the dgDataOfLine[tLine] of group "data" into tSelected
--check if there is an id for the row clicked
if tSelected[id] is a number then
--pull whatever data you want out of that array
put tSelected[id] into fld "id"
put tSelected[name] into fld "name"
put tSelected[email] into fld "email"
put tSelected[city] into fld "city"
put tSelected[state] into fld "state"
put tSelected[zip] into fld "zip"
put tSelected[phone1] into fld "phone1"
put tSelected[phone2] into fld "phone2"
put tSelected[company] into fld "company"
put tSelected[taddress] into fld "address"
highLightButtons tCard, tList
else
clearClient
end if
end selectClient
You can then use that function however you want, for example, on the dataGrid, edit the script like:
Code: Select all
on mouseUp
selectClient
end mouseUp
Re: Get content of DataGrid row with mouse double-click
Hi ghettocottage .... thanks for replay
I put this code into my table script and i create
some text field (No._fld, Name_fld, Laps_fld, Col5_fld)
but there is nothing happen, any advice?
I put this code into my table script and i create
some text field (No._fld, Name_fld, Laps_fld, Col5_fld)
but there is nothing happen, any advice?
Code: Select all
on mouseDoubleUp
//put the dgHilitedLines of group "riders_tbl" into theLine
selectClient
end mouseDoubleUp
/*********************************************************
select function --selecting a client from the datagrid
**********************************************************/
on selectClient
--get the number of the highlited row
put the dgHilitedLines of grp "riders_tbl" into tLine
--get the data of that line into an array
put the dgDataOfLine[tLine] of group "riders_tbl" into tSelected
--check if there is an id for the row clicked
if tSelected[id] is a number then
--pull whatever data you want out of that array
put tSelected[No.] into fld "No._fld"
put tSelected[Name] into fld "Name_fld"
put tSelected[Laps] into fld "Laps_fld"
put tSelected[Col5] into fld "Col5_fld"
highLightButtons tCard, tList
else
clearClient
end if
end selectClient
Gilar | from INDONESIA
Re: Get content of DataGrid row with mouse double-click
Hi friends,
non-numeric keys of arrays need to be in QUOTES unless we use a VARIABLE with that name for the key!
If not, I may produce unwanted results.
And where did you put that MOUSEUP handler?
A separate button?
Best
Klaus
non-numeric keys of arrays need to be in QUOTES unless we use a VARIABLE with that name for the key!
If not, I may produce unwanted results.
Code: Select all
...
put tSelected["id"]...
...
put tSelected["No."] into fld "No._fld"
put tSelected["Name"] into fld "Name_fld"
put tSelected["Laps"] into fld "Laps_fld"
put tSelected["Col5"] into fld "Col5_fld"
...
A separate button?
Best
Klaus
Re: Get content of DataGrid row with mouse double-click
I try delete some line of the code and it is work
delete this
and this
Now I try to change highlight color when mouse double click
Thanks
Code: Select all
on mouseDoubleUp
selectClient
end mouseDoubleUp
on selectClient
put the dgHilitedLines of grp "riders_tbl" into tLine
put the dgDataOfLine[tLine] of group "riders_tbl" into tSelected
put tSelected["No."] into fld "No._fld"
put tSelected["Name"] into fld "Name_fld"
put tSelected["Laps"] into fld "Laps_fld"
put tSelected["Col_5"] into fld "Col5_fld"
end selectClient
delete this
Code: Select all
--check if there is an id for the row clicked
if tSelected[id] is a number then
Code: Select all
highLightButtons tCard, tList
else
clearClient
end if
Thanks
Gilar | from INDONESIA
Re: Get content of DataGrid row with mouse double-click
Hi again Klaus ....
Best Regards
Gilar
Still got an error, after I delete some line of the script finally successKlaus wrote: ↑Mon Sep 10, 2018 1:26 pmCode: Select all
... put tSelected["id"]... ... put tSelected["No."] into fld "No._fld" put tSelected["Name"] into fld "Name_fld" put tSelected["Laps"] into fld "Laps_fld" put tSelected["Col5"] into fld "Col5_fld" ...
No. I put it on DataGrigAnd where did you put that MOUSEUP handler?
A separate button?
Best Regards
Gilar
Gilar | from INDONESIA
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: Get content of DataGrid row with mouse double-click
Code: Select all
--check if there is an id for the row clicked
if tSelected[id] is a number then
Out of curiousity, does your highlighted row change color at all? I think mine changes to a bright blue color when selected. I do not remember doing anything to make that happen (default behavior I think)
Re: Get content of DataGrid row with mouse double-click
Finally i can make it with this code
Thank you ghettocottage and Klaus for the Advice
God bless you all
Best Regards
Gilar Kadarsah
Code: Select all
on mouseDoubleUp
//put the dgHilitedLines of group "riders_tbl" into theLine
selectClient
end mouseDoubleUp
on selectClient
if the dgprop["hilite color"] of group "riders_tbl" is "0, 255, 255" then
set the dgprop["hilite color"] of group "riders_tbl" to "255, 0, 0"
--get the number of the highlited row
put the dgHilitedLines of grp "riders_tbl" into tLine
--get the data of that line into an array
put the dgDataOfLine[tLine] of group "riders_tbl" into tSelected
--check if there is an id for the row clicked
//if tSelected["id"] is a number then
--pull whatever data you want out of that array
put tSelected["No."] into fld "No._fld"
put tSelected["Name"] into fld "Name_fld"
put tSelected["Laps"] into fld "Laps_fld"
put tSelected["Col_5"] into fld "Col5_fld"
else
set the dgprop["hilite color"] of group "riders_tbl" to "0, 255, 255"
end if
//highLightButtons tCard, tList
//else
//clearClient
//end if
end selectClient
God bless you all
Best Regards
Gilar Kadarsah
Gilar | from INDONESIA