Sorting Timeline Names

Hi,

I can’t figure out how to sort the timeline by name. The URL manipulation doesn’t seem to work.

Thoughts?

Thanks

Hello,

Url manipulation?
You need to update list of timeline options but now in required order.
[ {key:1, label: “Zzzz”}, {key: 5, label: “Aaaa”} ]
sort it in js and update in options:
[ {key: 5, label: “Aaaa”}, {key:1, label: “Zzzz”} ]

Kind regards,
Ilya

Yeah, there was some documentation that alluded to being able to load your connector with a specific sort requirement;

http://docs.dhtmlx.com/doku.php?id=dhtmlxconnectornet:url_manipulation

Based on your response; how would you sort this list if it came in via ‘serverList’?

Can it be done server-side?

Sorting through connector will work only for main dataset ( events ) and will not change order of options labels (timelines)

If you are using sub-connector to fetch list of timeline names, you can use render_sql command with it and in render_sql define full sql query with ORDER BY instruction to define sorting order

Blank Stare

Sorry, but I program most of my stuff by blind luck!

I have this in the events.php file that is called by the .load command;

$list = new OptionsConnector($res); $list->render_table("user","user_id","user_id(value),username(label)");

Where would I use this render_sql?

Sorry. And Thanks :slight_smile:

I tried this, but just got an empty table;

//$list->render_table("user","user_id","user_id(value),username(label)"); $list->render_sql("SELECT username FROM user ORDER BY username","user_id","user_id(value),username(label)");

You are on the right way :slight_smile:, just change your code line in the next way

$list->render_sql("SELECT user_id as value, username as label FROM user ORDER BY username","user_id","user_id(value),username(label)");

BANG!

You guys sure know your stuff! I bet all this would take you seconds to my many many hours!!

So, now I am thinking; I am storing my names as “Firstname Lastname”. But what if I wanted to do the table sort based on their Lastname - not Firstname!?

And if the above was possible - how could I set a variable up to determine how I would like to sort it?

Thanks heaps!

So, now I am thinking; I am storing my names as “Firstname Lastname”. But what if I wanted to do the table sort based on their Lastname - not Firstname!?

You will need to have the separate fields in Db for first and last name in such case
IF you will have

  • firstName
  • lastName

you can use

$list->render_sql(“SELECT lastName,user_id,CONCAT(firstName,’ ',lastName) as label FROM user ORDER BY lastName”,“user_id”,“user_id(value),username(label)”);

Also, if you prefer to use custom code - you can extract data from db and sort it by any kind of custom code, and later use

$scheduler->set_options(“name”, $array_of_data);
Where $array_of_data - array which you custom code will generate.