Extra details on DataBound

Hi, I am using EJ1 Grid.


It loads its data from an URL (MVC controller)

in the controller, I return something like 
 return this.Json(new {result = data, count = dt.TotalCount, dero = "some value"}, JsonRequestBehavior.AllowGet);


Result & count are used by the grid, but how do I get, on the client-side, that dero field?

Tried on the dataBound event, with no success.

Thanks!


3 Replies 1 reply marked as answer

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 17, 2021 01:38 PM UTC

Hi Catalin, 

Thanks for contacting Syncfusion Support. 

Query#:- Result & count are used by the grid, but how do I get, on the client-side, that dero field? 
 
To achieve this requirement we suggest you to use custom adaptor in the Grid in which we can pass a message to the client from the controller. In the custom adaptor, processResponse has to be overridden to process the data from the server. We have extended processResponse method of the ej.UrlAdaptor and in the extended method we can get the required details from server end.  
The custom adaptor has been assigned in the Load event.  

Refer to the code below:- 
 
@(Html.EJ().Grid<OrdersView>("Grid") 
                    .Datasource(ds => ds.URL("/Grid/UrlDataSource"). 
                    .Adaptor(AdaptorType.UrlAdaptor)) 
                    .AllowPaging() 
                    .ClientSideEvents(eve => { 
                          eve.Load("onLoad"); 
                    }) 
 
                    .Columns(col => 
                    { 
                        col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); 
                        .      .     . 
                    }) 
    ) 
 
<script> 
 
    function onLoad(args) { 
        this.model.dataSource.adaptor = new customAdaptor();//extend the adaptor       
    } 
 
    var customAdaptor = new ej.UrlAdaptor().extend({ 
           processResponse: function (data, ds, query, xhr, request, changes) { 
            if (!ej.isNullOrUndefined(data.dero)) 
                alert(data.dero);       //get the required details here 
            var obj = ej.UrlAdaptor.prototype.processResponse(data, ds, query, xhr, request, changes); 
            return obj; 
        }, 
    });  
</script> 

Refer to the documentation and API Link:- 

Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


Marked as answer

CR Catalin Radoi May 7, 2021 12:59 PM UTC

Thank you, Farveen Sulthana, works great.


PK Padmavathy Kamalanathan Syncfusion Team May 10, 2021 01:16 PM UTC

Hi Catalin, 
 
We are glad to hear that you have achieved your requirement. 
 
Kindly get back to us for further assistance. 
 
Regards, 
Padmavathy Kamalanathan 


Loader.
Up arrow icon