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

List Bound Grid renders empty DIV

Well, I'm trying to get started with the Syncfusion Grid and I'm off to a frustrating start.  I'm assuming this is something simple, as I'm not finding many other posts about this.  I copied the List binding demo and tweaked it.  However, despite everything working through the process, the EJ helper renders an empty <div> tag out to the browser.

Page Content:

            @(Html.EJ().Grid<uploadedFile>("FilesGrid")
        .Datasource(.Datasource((IEnumerable<object>)ViewBag.datasource))
        .AllowSorting()
        .AllowPaging()
        .IsResponsive()
        .Columns(col =>
        {
            col.Field("fileID").HeaderText("file ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
            col.Field("fileName").HeaderText("File Name").TextAlign(TextAlign.Right).Priority(4).Width(75).Add();
            col.Field("approvalID").HeaderText("approval ID").Width(80).Add();
            col.Field("fileContents").HeaderText("File Contents").TextAlign(TextAlign.Right).Priority(4).Width(75).Add();
            col.Field("comments").HeaderText("Comments").TextAlign(TextAlign.Right).Width(75).Priority(3).Format("{0:C}").Add();
            col.Field("uploadDate").HeaderText("Upload Date").TextAlign(TextAlign.Right).Width(80).Priority(2).Format("{0:MM/dd/yyyy}").Add();
            col.Field("uploadedBy").HeaderText("User").Width(110).Priority(2).Add();
            col.Field("fileHash").HeaderText("File Hash").TextAlign(TextAlign.Right).Priority(4).Width(75).Add();
            col.Field("fileType").HeaderText("File Type").TextAlign(TextAlign.Right).Priority(4).Width(75).Add();

        }))

Controller Code:

        public ActionResult FileListing()
        {

            using(FileUploadContext dbContext=new FileUploadContext())
            {
                ViewBag.datasource = dbContext.uploadedFiles.ToList();
            }

            return View();
        }


The controller populates the datasource with around ten record, which I can step through on a debug do indeed get picked up by the EJ.Grid constructor.  However, all that ever gets spit out to the page is:       "<div id="FilesGrid"></div>"

I have all scripts and them files located in the project.  Again, I'm sure it's something simple, but I'm not seeing it.
Any insight or help would be appreciated.

1 Reply

RS Renjith Singh Rajendran Syncfusion Team August 24, 2017 07:20 AM UTC

Hi Jason, 

We have analyzed your query, We suspect that you are using unobtrusive mode. To make use of Unobtrusive support with our Essential JavaScript components, it is necessary to refer the ej.unobtrusive.min.js file under the _Layout.cshtml in your application. The ej.unobtrusive.min.js script should be referred next to ej.web.all.min.js file reference since it is dependent on it. Please refer the code below, 

Web.config 
  <appSettings>  
    ... 
   <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    ... 
 </appSettings> 

_Layout.cshtml 
<script src="~/Scripts/ej.unobtrusive.min.js"></script> 

If you are using non-unobtrusive mode, we suspect that you have not added the ScriptManager in _Layout.cshtml in your application. Please refer the code below. 

Web.config 
  <appSettings>  
    ... 
   <add key="UnobtrusiveJavaScriptEnabled" value="false" /> 
    ... 
 </appSettings> 

_Layout.cshtml 
<body> 
    @RenderBody() 
    @Html.EJ().ScriptManager(); 
</body> 

We have also prepared a sample based on your requirement, which can be downloaded from the following link, 

Please refer the documentation link below, 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon