Syncfusion.JavaScript.GridPropertiesBuilder Error

Im getting this error, Syncfusion.JavaScript.GridPropertiesBuilder`1[myModelName] , on my page instead of the grid displaying data, Im new to Syncfusion so unsure what the problem is, I think I have all the files etc referenced correctly as I have another grid displaying data on the same page from an example I found in online documentation that uses a web service

View

//This doesnt work

@(Html.EJ().Grid<myModelName>("Grid2")

.Datasource((IEnumerable<myModelName>)ViewBag.dataSource)

.Columns(col =>

{

col.Field(p => p.ReferenceNumber).HeaderText("Reference Number").TextAlign(TextAlign.Center).Add();

col.Field(p => p.Title).HeaderText("Title").TextAlign(TextAlign.Center).Add();

col.Field(p => p.FullName).HeaderText("FullName").TextAlign(TextAlign.Center).Add();

}))

 


//This works

<ej-grid id="FlatGrid" allow-sorting="true" allow-paging="true">

<e-datamanager url="http://mvc.syncfusion.com/Services/Northwnd.svc/Orders/?$top=45" offline="true"></e-datamanager>

<e-columns>

<e-column field="OrderID" header-text="Order ID" text-align="Right" width="75"></e-column>

<e-column field="CustomerID" header-text="Customer ID" width="80"></e-column>

<e-column field="EmployeeID" header-text="Employee ID" text-align="Left" width="75"></e-column>

<e-column field="Freight" header-text="Freight" format="{0:C2}" text-align=Right width="75"></e-column>

<e-column field="OrderDate" header-text="Order Date" format="{0:MM/dd/yyyy}" text-align=Right width="80"></e-column>

<e-column field="ShipCity" header-text="Ship City" width="110"></e-column>

</e-columns>

</ej-grid>



Controller



public IActionResult Index()
{


 ViewBag.dataSource= Repository.GetLatestData().ToList();


 return View();


}


I have debugged the code and there is 18 records being brought back into the ViewBag.

Any ideas what I could be doing wrong?


Thanks



5 Replies

GW Gary Whiteside November 8, 2016 03:27 PM UTC

Could I be mixing up MVC and Core?


JK Jayaprakash Kamaraj Syncfusion Team November 9, 2016 01:49 PM UTC

Hi Gary, 
 
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, 
 
Jayaprakash K. 



JK Jayaprakash Kamaraj Syncfusion Team November 9, 2016 01:51 PM UTC

Hi Gary, 
 
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, 
 
Jayaprakash K. 



GW Gary Whiteside November 10, 2016 10:52 AM UTC

Got it working thanks


JK Jayaprakash Kamaraj Syncfusion Team November 11, 2016 08:38 AM UTC

Hi Gary,  
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.   
 
Regards,  
 
Jayaprakash K. 


Loader.
Up arrow icon