Get KoolPHP UI with 30% OFF!

Problem with sorting (order by)

Igor
I made master - detail view. When i try to sort detail table (with sql query) nothing happens. KoolGirid sorting is working, but i want to show data already sorted by timestamp field.
Sql query works in phpmyadmin.
Here is the code:
	$ds_bitno->SelectCommand ='
	SELECT klijent, zadnja_napomena, date_format(timex , "%m-%d-%Y %H:%i:%s") as timex
	FROM nazvatiHist
	ORDER BY timex DESC';
	$table_order_detail = new GridTableView(); 
	$table_order_detail->Width = "100%";
	$table_order_detail->DataSource = $ds_bitno;
	$table_order_detail->AddRelationField("klijent","klijent");
	// $table_order_detail->AllowSorting = true;
	$table_order_detail->AutoGenerateColumns = true;//Auto Generate all column from tables
	// $table_order_detail->AllowFiltering = false;//Enable filtering for all rows;
	$table_order_detail->DisableAutoGenerateDataFields = "id, username, klijent";//Disable generate column for orderNumber data fields.
	

name, datatype, format
timex, datetime, CURRENT_TIMESTAMP
I also try many combinations with:
  1. (UNIX_TIMESTAMP(timex)),
  2. ORDER BY STR_TO_DATE(timex , "%m-%d-%Y %H:%i:%s") DESC
  3. SELECT date_format(timex, "%d-%m-%Y")

Anybody?
Tnx
Igor
Posted Mar 28, 2016 , edited Mar 28, 2016 Kool
Igor
Solved!
	$ds_bitno->SelectCommand ='SELECT 
		@curRow := @curRow + 1 AS RBroj,
		x.klijent,
		x.zadnja_napomena, 
		x.sljedece_zvanje,
		x.rezerviran_do
		FROM    nazvatiHist x
		JOIN    (SELECT @curRow := 0) r
		where username= "'.$_SESSION['login_user'].'"
		ORDER BY RBroj DESC
		';	
Posted Mar 31, 2016 , edited Mar 31, 2016 Kool