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

Render Grid when UnobtrusiveJavaScriptEnabled is TRUE

I am trying to use the MVC Grid control in an existing MVC5 project. I have to keep UnobtrusiveJavaScriptEnabled to true in order for the rest of the website to work.
I have added the CDN for the ej.unobtrusive.min.js file with the other scripts links thatare required in the scripts section of the webpagethat I am using Syncfusion on:
@section scripts {





@Scripts.Render("~/Scripts/edit-consignments.js")
}

I didn't include the main jquery file on this page because it is included in the _Layout page. I took out the ScriptManager, as instructed.
I get the Grid Headers rendered but no data. So I tried a ListBox on the page instead, and all I get is a box outline. If I turn off UnobtrusiveJavaScriptEnabled in the web.config and add in the ScriptManager, it works. But I can't turn this off for the entire site - I need it everywhere but this page.
How do I get this to work?
Cindy

4 Replies

CK Cindy Kee March 30, 2016 01:28 AM UTC

When I posted the question, I lost the scripts section of my file. Here it is again:

@section scripts {
    <script src="http://cdn.syncfusion.com/js/assets/external/jquery.easing.1.3.min.js"></script>
    <script src="http://cdn.syncfusion.com/js/assets/external/jsrender.min.js"></script>
    <script src="http://cdn.syncfusion.com/js/assets/external/jquery.globalize.min.js"></script>
    <script src="http://cdn.syncfusion.com/13.4.0.63/js/web/ej.web.all.min.js"></script>

    <script src="http://cdn.syncfusion.com/13.4.0.63/js/common/ej.unobtrusive.min.js"></script>

    @Scripts.Render("~/Scripts/edit-consignments.js")
}


GV Gowthami V Syncfusion Team March 30, 2016 11:30 AM UTC

Hi Cindy,

Thanks for using Syncfusion products.

We have analyzed your issue and we suspect that you may refer the script files after the grid has rendered. So that only the grid is not rendered.

We can resolve the issue by set the “InitUnobtrusiveInScriptManager” as “true” under appSettings in web.config as follows,

web.config


<appSettings>

    . . . .

    . . . .

    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>

    <add key="InitUnobtrusiveInScriptManager" value="true"/>
 </appSettings>

_Layout.cshtml

<body>
. . . .

. . . .

@RenderSection("scripts", required: false)


@Html.EJ().ScriptManager()     @*At last call ScriptManager method*@

   

</body>


While using above solution we need to call the ScriptManager method in _Layout.cshtml page.

The scripts will be referred based on the ScriptManager method placed in the _Layout.cshtml. So refer all the scripts before the ScriptManager method.

For your convenience we have created a sample and the same can be referred from the following link,

http://www.syncfusion.com/downloads/support/directtrac/123549/SAE851~1222382020.ZIP

If we misunderstood your issue please provide us the more details about your issue like the script error details thrown in console (developer tool) which will help to analyze the issue and provide you the response as early as possible..

Regards,

Gowthami V.



CK Cindy Kee April 5, 2016 11:05 PM UTC

Thank you! That worked!

The 2 key things I was missing was the new key in the web.config (<add key="InitUnobtrusiveInScriptManager" value="true"/>) and then making sure the ScriptManager comes AFTER the all of the scripts.

I integrated those changes into my test project, and now things work with the UnobtrusiveJavaScriptEnabled set to true.  :)

Thanks again,
Cindy



RU Ragavee U S Syncfusion Team April 6, 2016 04:37 AM UTC

Hi Cindy,

Thanks for your update.

We are happy that your requirement is achieved.

Regards,
Ragavee U S.

Loader.
Live Chat Icon For mobile
Up arrow icon