Selecting multiple lines in a datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Selecting multiple lines in a datagrid
I completely get selecting 1 line in a data grid and using the data, that part is no problem.
What I need to do is select multiple lines of a datagrid and then save all those selected lines into a text file, I cant seem to find any answers to this. someone please help.
What I need to do is select multiple lines of a datagrid and then save all those selected lines into a text file, I cant seem to find any answers to this. someone please help.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Selecting multiple lines in a datagrid
Ah, DataGrids.
Try this:
That said, I always extract the data either with the "dgData or the "dgText", manipulate the information, and then restore as needed.
Craig Newman
Try this:
Code: Select all
on mouseUp
set the dghilitedLines of grp "yourDG" to 2,4
end mouseUp
Craig Newman
Re: Selecting multiple lines in a datagrid
Craig's comment will let you use code to select multiple lines. If you are trying to let the user do it for themselves, there are two things:
1) For a desktop app, in the properties of a dg, there is a "multiple lines" checkbox. Select that, and the user can use the shift key to select additional lines.
2) On mobile, you have to code it yourself, because there is no shift key for the user to hold down while tapping on multiple lines in the dg. In that case,
1) For a desktop app, in the properties of a dg, there is a "multiple lines" checkbox. Select that, and the user can use the shift key to select additional lines.
2) On mobile, you have to code it yourself, because there is no shift key for the user to hold down while tapping on multiple lines in the dg. In that case,
- Make your columns the full width of your datagrid b/c otherwise handling the mouseUp message will get to be tricky
- Turn off the auto hilite of the datagrid (properties palette)
- Write a mouseUp handler that will deal with it. That can look something like this:
Code: Select all
on mouseUp put the dgHilitedLines of me into theHilitedLinesOfMe put the dgindex of the target into theTarget #need to use the target and not me b/c the target receives the message and the target will be one of the columns #<check if the line selected is already lit. If it is, unlight it, clean up the screen and the lists> repeat with i = 1 to the number of items in theHilitedLinesOfMe if item i of theHilitedLinesOfMe is theTarget then #in the list, already, nuke it and move on delete item i of theHilitedLinesOfMe set the dgHilitedLines of me to theHilitedLinesOfMe exit mouseUp # found and deleted so we're done, here. end if #item i of theHilitedLinesOfMe is theTarget end repeat # with i = 1 to the number of lines in theHilitedLinesOfMe #</check if the line selected is already lit. If it is, unlight it, clean up the screen and the lists> end mouseUp
Re: Selecting multiple lines in a datagrid
yeah I got that far1) For a desktop app, in the properties of a dg, there is a "multiple lines" checkbox. Select that, and the user can use the shift key to select additional lines.

What I can't seem to find or figure out is now that I have 3 lines selected, How do I go about sending those selected lines to a text file?
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Selecting multiple lines in a datagrid
the dgHilitedIndexes --> specifies the indexes of the selected linesDavJans wrote:... How do I go about sending those selected lines to a text file?
getDataofIndex(pIndex) --> gets you the data array for a given index
combine --> converts an array into a list
put --> puts the list into a container, including a text file
Regards,
Sri
Re: Selecting multiple lines in a datagrid
Thank you.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Selecting multiple lines in a datagrid
For those that come along, later, and find this topic, I submitted a bug report (including a FIX) for mobile.
The report number is 15240, and it also includes the fixed datagrid library, if you want to download it before the FIX is accepted and incorporated into a future version of LC.
For the record, only one of my prior FIX reports has not been built into the IDE, yet, which is more a testament to LC taking FIX reports seriously than it is my skill at adding 15 or so characters to a script to add some new feature for mobile. The DataGrid is so easy to work on and understand that all it has taken for each of my mobile FIXes is maybe one line of code each time.
The report number is 15240, and it also includes the fixed datagrid library, if you want to download it before the FIX is accepted and incorporated into a future version of LC.
For the record, only one of my prior FIX reports has not been built into the IDE, yet, which is more a testament to LC taking FIX reports seriously than it is my skill at adding 15 or so characters to a script to add some new feature for mobile. The DataGrid is so easy to work on and understand that all it has taken for each of my mobile FIXes is maybe one line of code each time.
Re: Selecting multiple lines in a datagrid
I have run into a problem with my script, It works great if I don't sort my data at all, but if I do sort the data I get the wrong information, here is my script, if anyone has any information that could help that would be great.
Code: Select all
on mouseUp
put empty into fld "Field1"
put the dgData of group "DataGrid 1" into tData1
put the dgHilitedLines of group "DataGrid 1" into tIndexes
repeat for each item tIndex in tIndexes
put tData1[tIndex]["cert"] & comma after fld "Field1"
put tData1[tIndex]["job"] & comma after fld "Field1"
put tData1[tIndex]["minorpcmkid"] & comma after fld "Field1"
put tData1[tIndex]["heat"] & comma after fld "Field1"
put tData1[tIndex]["creationdate"] & cr after fld "Field1"
end repeat
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Selecting multiple lines in a datagrid
Do you redraw the DG after the sort?
Do you allow multiple lines to be selected?
Does the line selection happen before the sort?
By "the wrong information" do you mean that you wind up with information from the wrong line?
There is not enough info in your code sample for me to give you a suggestion.
Do you allow multiple lines to be selected?
Does the line selection happen before the sort?
By "the wrong information" do you mean that you wind up with information from the wrong line?
There is not enough info in your code sample for me to give you a suggestion.
Re: Selecting multiple lines in a datagrid
Do you redraw the DG after the sort?
Don't know?
Do you allow multiple lines to be selected?
Yes
Does the line selection happen before the sort?
I sort, then select the lines I want.
By "the wrong information" do you mean that you wind up with information from the wrong line?
Yes. I get the information that was at that line before I sorted.
Don't know?
Do you allow multiple lines to be selected?
Yes
Does the line selection happen before the sort?
I sort, then select the lines I want.
By "the wrong information" do you mean that you wind up with information from the wrong line?
Yes. I get the information that was at that line before I sorted.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Selecting multiple lines in a datagrid
OK, I think I'm going to need to see more to offer more help.
Re: Selecting multiple lines in a datagrid
OK, I made a new stack.
real simple 1 datagrid 1 field 1 button. 4 columns and 5 rows of data
if you select any row and push the button you will get the same data in the field. If you sort the datagrid by any column so that it's opposite, highlight any row except the third, when you push the button you will get the wrong data in the field.
real simple 1 datagrid 1 field 1 button. 4 columns and 5 rows of data
if you select any row and push the button you will get the same data in the field. If you sort the datagrid by any column so that it's opposite, highlight any row except the third, when you push the button you will get the wrong data in the field.
- Attachments
-
- DataGrid problem.zip
- (5.3 KiB) Downloaded 264 times
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Selecting multiple lines in a datagrid
OK, NOW I understand.
DG's are just groups of LC objects, with a behavior script. There are two different data pieces in a DG: How it's organized internally, and how it's organized for you to view it. DataGrids don't reshuffle themselves internally when you sort them. The indexes remain the same. Use dgDataOfLine[tIndexes] to get the array of columns that are hilited. Then you can walk the columns.
DG's are just groups of LC objects, with a behavior script. There are two different data pieces in a DG: How it's organized internally, and how it's organized for you to view it. DataGrids don't reshuffle themselves internally when you sort them. The indexes remain the same. Use dgDataOfLine[tIndexes] to get the array of columns that are hilited. Then you can walk the columns.
Re: Selecting multiple lines in a datagrid
Thank you kind sir.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Selecting multiple lines in a datagrid
Working on this again, here is what I got so far.
This seems to work properly for 1 line at a time, but I cant figure out how to get every line.
Code: Select all
put the dgHilitedLines of group "DataGrid 1" into theLine
put the dgDataOfLine[theLine] of group "DataGrid 1" into tData1
put tData1["cert"] & comma after fld "Field1"
put tData1["job"] & comma after fld "Field1"
put tData1["minorpcmkid"] & comma after fld "Field1"
put tData1["heat"] & comma after fld "Field1"
put tData1["creationdate"] & cr after fld "Field1"
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här