Page 1 of 1

Data Grid sort column does not work

Posted: Wed May 23, 2018 10:26 am
by mrcoollion
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

Re: Data Grid sort column does not work

Posted: Wed May 23, 2018 11:33 am
by mrcoollion
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

Re: Data Grid sort column does not work

Posted: Wed Jun 06, 2018 4:17 am
by quailcreek
How do you have the columns set in the PI of the DG?

Re: Data Grid sort column does not work

Posted: Wed Jun 06, 2018 12:30 pm
by mrcoollion
DG Style is table
Column Sort options : Ascending and Text
Did not select sort by column.
Did not select case sensitive.


Regards,

Paul

Re: Data Grid sort column does not work

Posted: Mon Jun 11, 2018 10:06 am
by sphere
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

Re: Data Grid sort column does not work

Posted: Tue Jun 12, 2018 12:16 am
by quailcreek
Did you try selecting Sort by Column in the DG PI?

Re: Data Grid sort column does not work

Posted: Tue Jun 12, 2018 11:23 am
by sphere
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.

Re: Data Grid sort column does not work

Posted: Tue Jun 12, 2018 1:16 pm
by mrcoollion
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

Re: Data Grid sort column does not work

Posted: Tue Jun 12, 2018 7:52 pm
by sphere
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: