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. Image for the cookie policy date

Simple Grid

New to syncfusion and having great difficulty in rendering a simple grid, have gone through circular reference issues and such like but now can render the grid but there's no data rendering, 
controller
  public ActionResult Index()
        {

            ViewBag.datasource = db.Users.ToList();
            return View();
        }

View
@using WMS.Models

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>

@(Html.EJ().Grid<User>("Grid")
               .Datasource((IEnumerable<User>)ViewBag.datasource)
)





3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team December 23, 2016 11:14 AM UTC

Hi Stephen, 

Thanks for contacting Syncfusion support. 

            Queries 
                                          Response 

Circular Reference issues 


The circular reference error in data is resolved by using the select method. The following error is due to when we have same table, then object cannot be serialized. So, we suggest you to use select method to get the selected data from the table. For the following error please refer this link 

Please find the below code snippet for avoid the circular reference error: 
 
NORTHWNDEntities ds = new NORTHWNDEntities(); 
IEnumerable DataSource = OrderRepository.GetAllRecords(); 
DataSource = ds.Orders.Include("Customer").ToList(); 
result.result = DataSource.Cast<Order>().Select(x => new 
{ 
OrderID = x.OrderID, 
CustomerID = x.CustomerID, 
Freight = x.Freight, 
Customer = new 
{ 
CustomerID = x.Customer.CustomerID, 
}
}); 



Data is not rendered 


You have mentioned that data is not rendered on the grid. So, please confirm the following details to find out the root cause of the issue.  

1. Did you face any script error in the console? If yes, share the screenshot and stackrace of an issue. 

2. Ensure that you have referred the following script file in your sample. 


jquery.min.js 

jsrender.min.js 

ej.web.all.min.js 
 
If you enable the unobstrusive in the web.config, we suggest you to refer the ej.unobstrusive.min.js file in your sample. 
 


3. Code example of a Grid. 

4. Ensure that you have referred set “@Html.EJ().ScriptManager()” in _Layout file. The main reason for referring the ScriptManager in _Layout file is that, it can be referred as common by all the View files present within your application and it should be included in the _Layout.cshtml.  

5. Essential Studio Version details. 


Try the attached sample and still if you face the issue please provide above details it will helpful to provide the better solution.  

Refer to the Help document of Getting started. 

  



Regards, 
Prasanna Kumar N.S.V 



GS Grant Stephen January 6, 2017 02:35 PM UTC

any thanks, used a combination of Select new and viewModel 


PK Prasanna Kumar Viswanathan Syncfusion Team January 9, 2017 04:07 AM UTC

Hi Stephen, 

We are happy to hear that your issue has been resolved. 

Please let us know if you need any further assistance. 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon