DataGrid Table Column Reordering

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
Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

DataGrid Table Column Reordering

Post by Gage » Sat Dec 21, 2013 1:53 am

Hello,

I just completed a DataGrid Table, and noticed that by default, you can click the column headers and reorganize the data by alphabetical (or reverse-alphabetical) order. I placed the order in the dgData in a specific order, and do not want it to be sorted any other way.

Two questions:
1. How can I correct the DG to NOT sort the information I have in it, so that when I refresh it, the data displays as it should according to my loading handler? (I have scripted a bunch of the column behaviors, so I am hoping I don't have to totally delete this DG and make a new one)

2. How can I make it so clicking the column header does nothing, instead of sorting the dgData?

Thank you in advance for any help on this... hope you are having a wonderful winter so far!
Phil E.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: DataGrid Table Column Reordering

Post by Simon » Sat Dec 21, 2013 7:28 am

Hi Phil,
OK since no one else has answered this yet I'll give you a workaround...
Export snapshot of the DG, do a little cropping to get only the header then import the image and place it over the top of the DG. :D

This only works if the DG is non-resizable.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: DataGrid Table Column Reordering

Post by bangkok » Sat Dec 21, 2013 11:35 am

The easiest way :

in the DG script, put :

Code: Select all

on SortDataGridColumn pColumn
    --pass SortDataGridColumn
end SortDataGridColumn
That's all.
;-)

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: DataGrid Table Column Reordering

Post by Simon » Sat Dec 21, 2013 11:42 am

Code: Select all

on SortDataGridColumn pColumn
Way better!
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: DataGrid Table Column Reordering

Post by Gage » Sat Dec 21, 2013 6:12 pm

Simon,

Very creative first solution! I should think like that more...


Bangkok,

I think I will go with you on that one! That's exactly what I needed.


Thank you both!
Phil E.

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: DataGrid Table Column Reordering

Post by Gage » Sat Dec 21, 2013 6:22 pm

To help anyone else who is having similar issues, I realized that this topic is covered in the Tutorials in the Developer section of LiveCode.com, so I thought I would post the link to make the background information available, also.

http://lessons.runrev.com/s/lessons/m/d ... mn-sorting

Cheers!
Phil E.

Post Reply