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
close icon

Create Grid and bind to Model.

Hello

I am trying to create an ASP.NET MVC grid which binds to a model but it doesn't seem to render. I have used the VS extension to convert the project to Syncfusion MVC and have the following code:

Controller:

 [HttpGet]
        public ActionResult Create1()
        {   

        List<Customer_Customer> C = new List<Customer_Customer>();
                // add in items.

            return View(C);
        }

View:
@model IEnumerable<SyncfusionWebTest.Models.Customer_Customer>

@using System.Web.Mvc.Html;
@using Syncfusion.MVC.EJ;
@using Syncfusion.JavaScript;

@{
    ViewBag.Title = "Create1";
}

<h2>Create1</h2>

<div>
    @{(Html.EJ().Grid<SyncfusionWebTest.Models.Customer_Customer>("FlatGrid")
                        .Datasource((IEnumerable<SyncfusionWebTest.Models.Customer_Customer>)Model)
                        .AllowSorting()
                        .AllowPaging()
                        .Columns(col =>
                        {
                            col.Field(model => model.FirstName).HeaderText("a").IsPrimaryKey(true).Width(75).Add();
                            col.Field(model => model.LastName).HeaderText("a").Width(80).Add();

                        })).Render();
    }

//Test- This part is visible and contains data.
    @foreach (var item in Model)
    {
        <div>
            @Html.DisplayFor(modelItem => item.FirstName)
        </div>
        <div>
            @Html.DisplayFor(modelItem => item.LastName)
        </div>
    }
</div>



Also, I notice in the demo that you render two sections called "ControlsSection" and "SampleHeading" what are these used for and do I need to use these in my code? If so where do I find the scripts?

Thank You

1 Reply

SR Sellappandi Ramu Syncfusion Team November 30, 2015 07:06 AM UTC

Hi Patrick,

Thanks for contacting Syncfusion support.

Query #1: I am trying to create an ASP.NET MVC grid which binds to a model but it doesn't seem to render. I have used the VS extension to convert the project to Syncfusion MVC and have the following code:

We have tested the reported issue at our end using your codes, but it’s working fine. Please share the following information to us for short out the cause of the issue and provide the prompt solution.

1.       Check once whether Dll’s and Scripts are referred correctly, please clear the browser cache once and reload the sample.
2.       Screen shot of the network post, it will help us to found the any console error throws on loading.
3.       Kindly send us issue reproducing sample, it will help us to found the cause of the issue.
4.       Are you using the following VS extension to create the MVC project?


Please refer to the attached sample in below,


Sample: http://www.syncfusion.com/downloads/support/forum/121292/ze/MVCGrid_121292-1237216792


Query #2: Also, I notice in the demo that you render two sections called "ControlsSection" and "SampleHeading" what are these used for and do I need to use these in my code? If so where do I find the scripts? 


We have used these two section for sample browser samples demo. These sections are not important to render the controls.


Scripts are referred in _Layout.cshtml file under Views/Shared folder and the scripts are located in Scripts/ej folder.


Regards,

Sellappandi R


Loader.
Live Chat Icon For mobile
Up arrow icon