OrderBy
OrderBy
tdk
Posts: 32Questions: 16Answers: 0
I am using the .NET dll and want to order the data serverside before sending it to the client.
So I wanted to add this order option but there doesn't seen to be anyway to do this?
ORDER BY Cast(WorkTime as date) asc, DateAdd(hour, -8, Cast(WorkTime as time)) asc
e.g. something like this
var response = new Editor(db, "TableName", "Id")
.Debug(true)
.Model<Model>()
...
.Where("WorkDiaryDetail.WorkDiaryId", id)
.Order("Cast(WorkTime as date) asc, DateAdd(hour, -8, Cast(WorkTime as time)) asc")
.Process(request)
.Data();
This discussion has been closed.
Answers
Hi,
The ordering is specified by DataTables. If you are using client-side processing then the ordering is done client-side and if the default doesn't suit, a plug-in can be used.
If it is server-side processing then the ordering is performed by the SQL server on the column that DataTables it to sort by.
There is no
Editor.Order()
method, so you should be getting an error with the above code.Allan
Hi Allan,
The grid data is provided by the editor. The Editor.Order() was added just as an example of code I was hoping to use.
If I wrote it in SQL it would look like this
Cast(WorkTime as date) asc, DateAdd(hour, -8, Cast(WorkTime as time)) asc
Can DataTables work with formulas in the order field?
I think an enhancement to add OrderBy(string sql) would be very userful
As I say, I don't think an
Editor.OrderBy()
method would actually be any use since the sorting is normally done by the client-side software. If you are using server-side processing then the sorting is performed by the SQL server based on the column that the user has selected to sort by.The first question, therefore, is are you using client-side or server-side processing?
Allan