Show of hands, how many of you are using jqGrid? Alright, now how many of you have tried to run your ASP.NET MVC application in a configuration where the root of the application isn’t “/”? Alright, now raise your hand if you are having to edit jquery.jqGrid.js when you move the application to the alternate configuration?
NOTE: I’m assuming that your development environment runs with the application at the root of WebDev.WebServer.exe; if not, simply swap the assumptions, and I bet you still have the same problem I’m about to describe.
First, open up jquery.jqGrid.js and find the line where “pathtojsfiles” is defined. Delete it. Add a parameter of the same name (pathtojsfiles) to the jqGridInclude function, like so:
Next, jump to the end of the file, and remove this line:
Now, in your view markup, add a new script block after you’ve included jquery.jqGrid.js:
The down-side to this approach is that you’ve made (minor) modifications to jqGrid files, so you will need to re-apply this fix if you upgrade to a new release. But, that’s a small price to pay for eliminating a step from your deployment process.