Problem with datagrid and automatic sorting...

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

Post Reply
RevDevelopment
Posts: 13
Joined: Mon Feb 16, 2009 7:39 pm

Problem with datagrid and automatic sorting...

Post by RevDevelopment » Mon Apr 01, 2013 8:44 am

Hello,
I have an application that contains a datagrid with 3 columns.

Column 1 is a checkbox
Column 2 is a word
Column 3 is a number

In the application, the user is able to click the checkbox (column 1) and
use a right click menu to delete that row of the datagrid.

Or the user can check multiple checkboxes, and use the right click menu
to "delete all checked rows".

Here is the problem.

Let's say there are 300 rows in the datagrid, and a scrollbar is used to
scroll to the bottom rows of the datagrid.

When the user checks a checkbox after scrolling to the bottom, the entire datagrid then scrolls back
to the top, which keeps the user from checking more than one box at a time
when scrolled down and they are forced to then scroll back down again and check the next box, etc...

I was able to set a breakpoint and find the specific line of code that causes
the datagrid to scroll back to the top when a checkbox is checked.

41 lock screen
42 set the dgData of me to tArray
43 put the dgProp["sort by column"] of group "DataGrid 1" into tSortedColumn
44 send "SortDataGridColumn" && tSortedColumn to group "DataGrid 1"
45 unlock screen

In the above code, as soon as line 42 is executed, the datagrid automatically
scrolls back to the top.

Hope someone has some ideas to test. :)

Thank you!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10324
Joined: Wed May 06, 2009 2:28 pm

Re: Problem with datagrid and automatic sorting...

Post by dunbarx » Mon Apr 01, 2013 3:49 pm

Hi.

Things may be running normally, in that when you set the dgData to the array contents, the datagrid itself sort of reverts to its "natural" state, which is scrolled to 0.

I think.

Anyway, why not just store the scroll value right before the reload, and rescroll to that value?

Craig Newman

RevDevelopment
Posts: 13
Joined: Mon Feb 16, 2009 7:39 pm

Re: Problem with datagrid and automatic sorting...

Post by RevDevelopment » Tue Apr 02, 2013 12:25 pm

Craig,
Thank you for your help on this.

Let me try that and see if it might work. :)

Thanks!

RevDevelopment
Posts: 13
Joined: Mon Feb 16, 2009 7:39 pm

Re: Problem with datagrid and automatic sorting...

Post by RevDevelopment » Tue Apr 02, 2013 1:02 pm

Craig,
Thanks for the help...it worked! :mrgreen:

Post Reply