Binding a grid to the local model.

I'm trying to bind the ASP.NET Core Grid control to the enumerable view model on the page, e.g.


@model IEnumerable<SyncFusionTests.Web.Models.BeneficialOwnerIndexModel>

All the examples appear to be binding to a rest end point, however the documentation states:

You can bind the data to Grid control by either locally or remotely. Assign the remote service URL to e-datamanager property of Grid control to bind remote data using ej.DataManager.

But with no examples on how to bind locally.

How would I achieve this?

I've even tried defining the grid data source as:

<e-datamanager  url="Home/DataSource" offline="true"></e-datamanager>

With the associated method in the controller:

        public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm)
        {
            var DataSource = GetDummyBeneficialOwnersList();
            DataResult result = new DataResult();
            result.result = DataSource.Skip(dm.Skip).Take(dm.Take).ToList();
            result.count = DataSource.Count();
            return Json(result);
        }

But this didn't work either.

Preferably I'd like to be able to attach to the model associated with the page.

Thanks in advance,

Stuart.

3 Replies

SN Stuart Northcott November 11, 2016 10:09 AM UTC

Answered in this (later) thread: https://www.syncfusion.com/forums/127303/syncfusion-javascript-gridpropertiesbuilder-error


MF Mohammed Farook J Syncfusion Team November 11, 2016 10:40 AM UTC

 Hi Stuart 
In ASP.NET Core we need to render grid using Render method. Please refer to the below code example and sample.  
 
@{Html.EJ().Grid<object>("HierarchyGrid") 
                .Datasource(ds=>ds.Json(ViewBag.data)) 
                .AllowPaging() 
                .Columns(col => 
                { 
                    col.Field("OrderID").HeaderText("OrderID").Add(); 
                    col.Field("ShipCity").HeaderText("ShipCity").Add(); 
                    col.Field("Freight").Width(120).Format("{0:c2}").Add(); 
                }).Render(); 
}  
 

 
Regards, 
 
J Mohammed Farook



MF Mohammed Farook J Syncfusion Team November 11, 2016 10:41 AM UTC

 Hi Stuart 
 thanks for update. 
reards, 
J.Mohammed Farook 


Loader.
Up arrow icon