We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Binding a grid to the local model.

Thread ID:

Created:

Updated:

Platform:

Replies:

127374 Nov 10,2016 11:13 AM Nov 11,2016 05:41 AM ASP.NET Core 3
loading
Tags: Grid
Stuart Northcott
Asked On November 10, 2016 11:13 AM

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.

Stuart Northcott
Replied On November 11, 2016 05:09 AM

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

Mohammed Farook J [Syncfusion]
Replied On November 11, 2016 05:40 AM

 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


Mohammed Farook J [Syncfusion]
Replied On November 11, 2016 05:41 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;