datagrid column order

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
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

datagrid column order

Post by bsouthuk » Mon Dec 21, 2015 2:05 pm

Hi

Is it possible to change the order of the columns in a datagrid with a couple of lines of code or would it be a case of a loop formula and then setting the dgText of datagrid to ****

Cheers

Daniel

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

Re: datagrid column order

Post by Klaus » Mon Dec 21, 2015 2:25 pm

Hi Daniel,

sorry, no idea, but you could try to -> set the dgprops["columns"] of grp "your datagrid here" to XXX
to the new ordered list of column names and see what happens :D


Best

Klaus

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: datagrid column order

Post by bsouthuk » Mon Dec 21, 2015 2:38 pm

Thank you Klaus, I have tried

Code: Select all

 set the dgprops["columns"] of grp "Usage" to "TARIFF", "NETWORK", "MOBILE"
But this doesn't seem all the text just goes into the one column. I am having trouble separating them!

Any ideas?

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: datagrid column order

Post by bsouthuk » Mon Dec 21, 2015 2:41 pm

ITS OK I FORGET THE.. replace comma with return in *****

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: datagrid column order

Post by bsouthuk » Mon Dec 21, 2015 2:44 pm

OK so the issue I now have here is that the data that was stored in the Datagrid all disappears accept the first column...

Why on earth does this happen?

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

Re: datagrid column order

Post by Klaus » Mon Dec 21, 2015 2:49 pm

Obviously this is not the way to go... :D

But you tried this with a copy of your data, right? 8)

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: datagrid column order

Post by bsouthuk » Mon Dec 21, 2015 2:51 pm

Hi Klaus

I did yes, my datagrid was full of data, I used the following code:

Code: Select all

   put "CALL DATE, TARIFF, NETWORK" into tColumnTitles
   replace comma with return in tColumnTitles
   set the dgprops["columns"] of grp "Usage" to tColumnTitles
The column names changed correctly, but the only data within the Datagrid that remained for the first columns data.

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

Re: datagrid column order

Post by Klaus » Mon Dec 21, 2015 2:57 pm

As I said, this obviously does not work as exspected.

But make sure to remove unwanted spaces:
...
## put "CALL DATE, TARIFF, NETWORK" into tColumnTitles
put "CALL DATE,TARIFF,NETWORK" into tColumnTitles
...
See the difference? They might go into the new column names!
Not that this helps you with your problem.

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: datagrid column order

Post by bsouthuk » Mon Dec 21, 2015 3:02 pm

SORTED! Works perfectly, thank you for you help Klaus its very much appreciated.

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

Re: datagrid column order

Post by Klaus » Mon Dec 21, 2015 3:09 pm

So it DOES in fact work as exspected with the correct column names?
Cool! :D

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

Re: datagrid column order

Post by quailcreek » Tue Dec 22, 2015 4:53 am

I got caught up in something similar awhile ago. Just for reference, here's another way of stating the same thing.

Code: Select all

put ("CALL DATE", "TARIFF", "NETWORK") into tColumnTitle
Tom
MacBook Pro OS Mojave 10.14

Post Reply