Multi-Column Sorting Component/Library to parse orderby from request

I use the ejGrid and additionally Multi-Column Sorting option on few columns.
The parameter order by in request are different depend on my choice, like:

CompanyName,Id
Id,CompanyName desc
Id desc,CompanyName

Is there any library which can be used in ASP. NET Web Api to parse the options from parameter orderby in reqest.
To apply selected options in linq queries?

For query with parameter orderby: CompanyName, Id
In C# linq orderby(CompanyName) and ThenOrderby(Id)

1 Reply

VN Vignesh Natarajan Syncfusion Team October 27, 2017 03:56 PM UTC

Hi Maciej, 

Thanks for contacting Syncfusion support 
               
We have analyzed your query and we suspect that you want to modify the query while performing the MultiSorting in web API adaptor. We have achieved your query using customAdaptor in that we have extended the processQuery method of WebApiAdaptor and you can modify the query based on yours.  
Please refer the below code snippet 
var customAdaptor = new ej.WebApiAdaptor().extend({ 
         
        processQuery: function (dataObj, query, hierarchyFilters) { 
            query = ej.Query().sortBy("CustomerID", "descending").sortBy("EmployeeID", "ascending"// you can pass your own query here 
            var query = ej.WebApiAdaptor.prototype.processQuery.apply(this, [dataObj, query, hierarchyFilters]); 
            window.data = query.data; 
            return query; 
 
        } 
    }); 
. . . . .  
 
$(function () {     
        dataManager = ej.DataManager({ url: "/api/Orders", adaptor: new ej.WebApiAdaptor() }); 
        $("#Grid").ejGrid({ 
            dataSource: dataManager, 
            allowPaging: true, 
            allowSorting: true, 
. . . .  
 
 
  load: function (args) { 
                this.model.dataSource.adaptor = new customAdaptor();// 
            } 
 
Refer our online documentation for your reference 
 
 
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon