Data Grid sort column does not work

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Data Grid sort column does not work

Post by mrcoollion » Wed May 23, 2018 10:26 am

Hi guys and girls,

I am having trouble with the sorting of columns in my data-grid objects.
When I want to sort a column in my data-grid by clicking the column-header it freezes and I cannot select another row with data.
After I refresh the datagrid by leaving the card and go back again which effectively refills the datagrid in the preopencard section, the data-grid data is sorted according to the column i wanted it to sort by before it froze, and the data-grid works fine.

The data-grid is not actually frozen but I cannot select another row than the one that the data-grid has highlited at the moment i clicked the column-header. If I did not select a row before I clicked the column-header it auto-selects row 1. The objects code does stil work because the statement

Code: Select all

answer "theLine : "& theLine
gives me the same line number every-time after I try to click any row in the data-grid.

How can i solve this?
Is there a way to determain in the object code that I have clicked the column-header so I can refresh the datagrid after?

regards,

Paul

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Data Grid sort column does not work

Post by mrcoollion » Wed May 23, 2018 11:33 am

Got it working by adding the following code in the datagrid object

Code: Select all

on SortDataGridColumn pColumn
   ----------------------------
   ReverseSort pColumn
   ----------------------------
   put the dgHilitedIndex of  group "ApprovalQueue" into theIndex 
   lock screen
   send "mouseUp"to btn "RefillAQDG" // Refills the datagrid
   unlock screen
   set the dgHilitedIndex of  group "ApprovalQueue" to theIndex 
   ---------------------------------------------------------
end SortDataGridColumn
Stil think it should sort out of the box :roll:

Regards,

Paul

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: Data Grid sort column does not work

Post by quailcreek » Wed Jun 06, 2018 4:17 am

How do you have the columns set in the PI of the DG?
Tom
MacBook Pro OS Mojave 10.14

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Data Grid sort column does not work

Post by mrcoollion » Wed Jun 06, 2018 12:30 pm

DG Style is table
Column Sort options : Ascending and Text
Did not select sort by column.
Did not select case sensitive.


Regards,

Paul

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Data Grid sort column does not work

Post by sphere » Mon Jun 11, 2018 10:06 am

I use a piece of script too in the DG.
Will check it tonight when i'm home.
Don't have it with me now.

Groeten

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: Data Grid sort column does not work

Post by quailcreek » Tue Jun 12, 2018 12:16 am

Did you try selecting Sort by Column in the DG PI?
Tom
MacBook Pro OS Mojave 10.14

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Data Grid sort column does not work

Post by sphere » Tue Jun 12, 2018 11:23 am

Hi, i totally forgot yesterday.
But this is what i have in the DG script:

Code: Select all

on SortDataGridColumn pColumn
   if pColumn is "A column name" then
pass SortDataGridColumn
end if
if pColumn is "another column name" then
pass SortDataGridColumn
end if
end SortDataGridColumn
And just extend it for the columns you need
Hope you can use it.

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Data Grid sort column does not work

Post by mrcoollion » Tue Jun 12, 2018 1:16 pm

Thanks,

If I am correct the below code should work for any or all columns however it does not in my case.
Tried this and without actually refilling the DG it does not work.

Code: Select all

on SortDataGridColumn pColumn
      pass SortDataGridColumn
end SortDataGridColumn
Bedankt :D

Paul

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Data Grid sort column does not work

Post by sphere » Tue Jun 12, 2018 7:52 pm

Hi Paul,

it seems to work on my Datagrid, so i don't know why it does not at yours. I also do not need to reload it with data, if that is what you mean.

Before putting the data into the datagrid i do this:

Code: Select all

 dispatch "resetList" to group "DataGrid 1"
   set the dgProp["sort by column"] of group "DataGrid 1" of card 1 to empty
and after the datagrid is set to the data (putted the data into the grid)
i use this:

Code: Select all

set the dgProp["sort by column"] of group "DataGrid 1" of card 1 to "Nummer"
as mentioned here: http://lessons.livecode.com/m/datagrid/ ... y-a-column
Then is right away sorted by the wanted column for first use.

You can try to do as Quailcreek mentioned, but i checked i do not have it checked as it works with the DG script

Maybe pushing Refresh Datagrid in the Property Inspector does help?

Gij zijt welkom :lol:

Post Reply

Return to “Talking LiveCode”