1

I'm experimenting with JqGrid in the ASP.Net MVC 5 environment.

It seems that Jquery must be loaded before the code:@Html.Trirand().JQGrid(Model.ContactsGrid, "Grid")

But for best performance Jquery should be bundled and loaded at the end of the page.

Do I have to change this for pages that contain JqGrid?

John S
  • 7,909
  • 21
  • 77
  • 145
  • The MVC helper just writes js and html for the specific jqgrid table wherever the razor tag is placed. So, if jquery/jqgrid is at the bottom of the page, that block of js for the specific table is attempting to call jquery/jqgrid functions that haven't loaded. Couldn't the helper be rewritten to render just the html at the placement and add the js to a RenderSection script block? Then call RenderSection("otherscripts") at the bottom of the page after jquery/jqgrid calls? – Michael Finger Mar 18 '14 at 21:54

2 Answers2

1

jqGrid is jQuery plugin and so jQuery have to be loaded of cause before jqGrid. I think that if you would use <link> and <script> with src inside of <head> you will have also very good performance because the files will be get typically from the local cache of the web browser. If you still prefer to use bundles you can specify the order of JavaScripts which will be bundled. You can for example use Include method of files in the bundle in an explicit order (see the question for more details, the post and this one). In the way you will have no problem too.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
0

I think you can use Nuget package for jqgrid which will do it automatically.

Mir Gulam Sarwar
  • 2,588
  • 2
  • 25
  • 39