locking sort in a dataGrid column

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

locking sort in a dataGrid column

Post by dunbarx » Wed May 02, 2012 12:32 am

I want to lock the user out of being able to sort columns in a DG.

I can set the "sort by column" in the inspector to "false"

and I can:

set the dgColumnIsEditable["fade"] of grp "queue1" to "false",

but neither of these has any effect. If I click in the column header, a sort triangle appears, and the column is then sortable. Resetting from the inspector makes the sort arrow go away. Great. Is there no "lock" gizmo with teeth? Is this a bug?

I guess I can place a transparent object over the column headers, and head them off at the past.

Thanks.

Craig Newman

Klaus
Posts: 14212
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: locking sort in a dataGrid column

Post by Klaus » Wed May 02, 2012 10:44 am

Hi Craig,

verified with LC 5.02, the settings "Sort by column" is being ignored for ALL columns if you click the headers, big fun :-/
Looks like a bug, please write to: bugs@runrev.com


Best

Klaus

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: locking sort in a dataGrid column

Post by snm » Wed May 02, 2012 11:17 pm

Try to put handler:

on SortByColumn
end SortByColumn

in group "yourDataGrid"

Marek

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: locking sort in a dataGrid column

Post by Zryip TheSlug » Wed May 02, 2012 11:36 pm

dunbarx wrote:I want to lock the user out of being able to sort columns in a DG.

I can set the "sort by column" in the inspector to "false"

and I can:

set the dgColumnIsEditable["fade"] of grp "queue1" to "false",

but neither of these has any effect. If I click in the column header, a sort triangle appears, and the column is then sortable. Resetting from the inspector makes the sort arrow go away. Great. Is there no "lock" gizmo with teeth? Is this a bug?

I guess I can place a transparent object over the column headers, and head them off at the past.

Thanks.

Craig Newman
Hi Craig,

This is definitively not a bug.

The "sort by column" option in the inspector, allows to sort the datagrid by a specific column by default or to remove any default column sorting. Unchecking the check box, not disable the ability to sort a column in the datagrid by clicking on its header.

The correct way to really lock the column header is to add this handler in the datagrid group:

Code: Select all

on SortDataGridColumn pColumn
  ## Remain this handler empty for disabling the sort capability of a datagrid
end SortDataGridColumn

Best Regards,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

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

Re: locking sort in a dataGrid column

Post by dunbarx » Thu May 03, 2012 2:15 am

Thanks to both of you.

I checked the messageWatcher when clicking in a header, and among the 3000 messages sent, I see both " SortByColumn" and "SortDataGridColumn".

Dead giveaways. Trap and forget.

Craig

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: locking sort in a dataGrid column

Post by snm » Thu May 03, 2012 8:26 am

Hi Zryip,

Long time without new futures in DGH. Maybe next small but usefull is to click outside of DG or on header bar to "unsort"?

And second one - small graphics after last column header to trigger Sorting on/off while still have possibility to select column.

And one more thanks for "UTF-8" in DG field editor - it's still not native implemented in LC5.5

Marek

Post Reply