Prevent client sorting for the Grid

Using the actionBegin directive it is possible to subscribe for the Grid actions. Is it possible to stop event propagation inside the actionBegin handler?
In my case I need to perform server side sorting and paging. But the client side sorting is always applied before the API request for getting the data.

3 Replies

MF Mohammed Farook J Syncfusion Team October 16, 2018 11:47 AM UTC

Hi Stas, 
 
Thanks for contacting Syncfusion support. 
 
  1. In EJ2 Grid can support  to handle the grid action server side by default when using Data-Adaptors.  Please find the server code example
 
Code for server side operations, 
 
public ActionResult UrlDatasource(DataManagerRequest dm) 
        { 
            IEnumerable DataSource = order; 
            DataOperations operation = new DataOperations(); 
            List<string> str = new List<string>(); 
            if (dm.Search != null && dm.Search.Count > 0) 
            { 
                DataSource = operation.PerformSearching(DataSource, dm.Search);  //Search 
            } 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                DataSource = operation.PerformSorting(DataSource, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator); 
            } 
            int count = DataSource.Cast<Orders>().Count(); 
            if (dm.Skip != 0) 
            { 
                DataSource = operation.PerformSkip(DataSource, dm.Skip);         //Paging 
            } 
            if (dm.Take != 0) 
            { 
                DataSource = operation.PerformTake(DataSource, dm.Take); 
            } 
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 
 
 
  1. If you want to custom data binding with grid action, please refers the following documentation:
 
 
 
  1. We can prevent the sorting by setting ‘args.cancal as true’  in actionBegin event with requestType as ‘sorting’ (sorting action is completely disabled so any postback is not send to server ).  Please find the code example
 
 
. . . 
 
methods: { 
    actionBegin(args) { 
                if ((args.requestType === 'sorting')) { 
                          args.cancel = true; 
                                } 
                } 
 
 
 
This is not meet your requirement could you please explain more details about your requirement. 
 
Regards, 
J Mohammed Farook 
 



SV Stas Volyansky October 26, 2018 02:06 PM UTC

Yes. It helped. Thank you very much!


MF Mohammed Farook J Syncfusion Team October 29, 2018 04:26 AM UTC

Hi Stas,  
 
Thanks for your update. 
 
We are happy to hear that the provided solution has been resolved your problem. 
 
Regards,
J Mohammed Farook
 
 
 


Loader.
Up arrow icon