AJAX Server side sorting when using paging
AJAX Server side sorting when using paging

We use server side paging/sorting/filtering in c# / asp.net core and have an issue with rendered columns. For example, we have the following column made up from a class returned within the ajax call :
{
"data": "Person",
render: {
_: "FirstName",
sort: "FirstNameSort"
}
},
When the column heading is selected to change the sort order, the POSTed back info with the client/server side properties shows DTParameters.SortOrder = "Person" and not "FirstNameSort". This is obviously because that's the object's name but I would have "expected" this to have returned "FirstNameSort" as this is the sort column.
I appreciate that sort column convention works well on client side sorting, but how do you get "FirstNameSort" back to the server side without creating a condition for each column and checking the "type" of the column?
Thanks.
James.
This question has an accepted answers - jump to answer
Answers
Potentially answering my own question but hope it helps someone else (unless there is a better way).
We can use the "name" property to specify the sort column like this:
This name gets returned in the DTParameters object "Columns" property. We can then correlate the sort order column number with this column and use the "name" property(ies) for the dynamic order by clause.
Let me know if there is a "more correct" way.
Thanks again.
Yep, that's a good way to go,
Colin
Thank you as always Colin for your continued great work on this. Stay well.