Page 2 of 2
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 4:45 pm
by Klaus
Hi DavJans,
as the name suggests, "the dghiliteledLines" can ce more than one line!
So this should work:
Code: Select all
...
put the dgHilitedLines of group "DataGrid 1" into theLineS
repeat for each item tLine in tLines
put the dgDataOfLine[theLine] of group "DataGrid 1" into tData1
...
end repeat
...
Hint for speed!
Do NOT access fields inside of a repeat loop!
I you have to, always LOCK SCREEN first, or better collect all data in a variable
and then put the complete variable into the field after the loop!
Best
Klaus
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 5:04 pm
by DavJans
Code: Select all
put the dgHilitedLines of group "DataGrid 1" into theLineS
repeat for each line tLine in tLines
put the dgDataOfLine[theLineS] 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"
end repeat
something like this but not quite I guess? If i select 1 line it works, if more then not so much.
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 5:16 pm
by Klaus
I did not write that! Look again at my posting!
Hint: repeat for each ?
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 5:44 pm
by Mikey
WHOOPS! I see Klaus already weighed in, deleting my post...
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 5:52 pm
by Klaus
Sorry, made a typo, but the trick is to "repeat for each ITEM" (as I wrote!)
Please explain to yourself why your script DOES in fact work if only ONE line is selected!
Do this:
...
put the dgHilitedLines of group "DataGrid 1" into
theLineS
repeat for each
ITEM tLine in
theLineS
put the dgDataOfLine[
tLine] of group "DataGrid 1" into tData1
...
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 9:32 pm
by sritcp
Mikey:
I hear that Datagrid is so slow on mobile devices (esp iOS) as to be unusable. What is your experience (since you seem to have used it on mobile)?
Regards,
Sri
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 9:54 pm
by Mikey
Since you don't hear me complaining about it/freaking out about it/threatening to leave LC for some LISP or APL IDE, you can assume that it isn't true. We use DG's in every mobile app, including inventory apps, that can have hundreds of lines, and numerous columns (so they have to scroll both horizontally and vertically).
Having said that, the scrolling can be a PITA, if you want a native scroller. Monte's wrote a free dropTool for a native DG with scroller, but it doesn't lock the header when you scroll, so if you scroll down, the header will disappear. The old version of the same code works better for that, but the performance isn't as good. I use the old version because I want the headers to stay put.
Yes, there are flaws, but, every time we walk into a meeting and everyone else in the meeting has a stack of binders with information from their $3MM ERP system from their AS400 that is old news and took their staff hours to produce, and we walk in with phones and ipads with information that's litterally up-to-the-second, they don't really care if their paper looks pretty of if our apps aren't perfect. They just want to know why their IT department sucks so bad and ours doesn't.
Try it out for yourself. Build a test app with a DG, and prepopulate it with 100 rows or so. Then compare it to your current mobile solution. You might think DG's are just dandy.
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 10:09 pm
by DavJans
I would blame the fact that it is Friday but I's me. I cant seem to gather what I'm doing wrong.
Code: Select all
put the dgHilitedLines of group "DataGrid 1" into theLineS
repeat for each item tLine in tLineS
put the dgDataOfLine[tLine] 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"
end repeat
Whatever I did, it wont give me any data at all now, even with only 1 line selected.
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 10:20 pm
by Mikey
I'm not trying to be difficult, but have you tried using the debugger to see what the values are as you step through? I don't have time right now to futz with it for you.
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 10:25 pm
by DavJans
Nope you are fine.
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 10:32 pm
by DavJans
I got it, thank you all for your help.
here is the code for anyone else that stumbles here with the same question someday.
Code: Select all
put the dgHilitedLines of group "DataGrid 1" into theLineS
repeat for each item tLine in theLineS
put the dgDataOfLine[tLine] 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"
end repeat
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 10:50 pm
by Mikey
Those look the same to me. What did I miss?
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 11:38 pm
by sritcp
Mikey wrote:..... you can assume that it isn't true. We use DG's in every mobile app, including inventory apps, ...
Just what I wanted to hear! I have been using DG on my Mac for a while. I have 2000 rows and 25-30 columns in the master DG on the main card, and subsets of this data on DGs on subsequent cards, the master data editable from any card. Sometimes it is slow going from card to card (have to update the master each time), but otherwise works well. Naturally, my mobile DG will be much smaller in size (especially columns displayed), but wanted to hear from someone using it in real life.
Having said that, the scrolling can be a PITA, if you want a native scroller.
That was going to be my next question!
What about the DG's built-in scroller (on mobile)? Does that work at all (besides the usability problems due to its narrow size)? If it does, is a workaround possible to make it usable?
As for Monte's tool, you can always put a banner image to replace the header when it has scrolled out of view (as long as you don't try to sort a column), can't you?
Also, how about an external slider (and linking it to the visible lines of DG)? Just throwing some ideas at you.
Thanks for the feedback. I feel much better.
Regards,
Sri
Re: Selecting multiple lines in a datagrid
Posted: Fri Nov 06, 2015 11:39 pm
by DavJans
I honestly couldn't tell you, comparing the two posts I don't see a difference, but it works now, and it didn't earlier.