asp.net mvc 3 - jqGrid dose not work when i run from IIS 7.2 (virtual directory) -
expert,
i have created 1 application , implemented jqgrid add, edit , delete, this working fine running visual studio 2010.
now created virtual directory application , trying access index page not displaying because jqgrid not loaded giving me following errr: error: jquery("#list").jqgrid not function source file: http://localhost/cafm/tabmaster line: 58
here jqgrid code snippet.
jquery(document).ready(function () { alert(jquery("#list")); jquery("#list").jqgrid({ url: '/tabmaster/jqgridgetgriddata', datatype: 'json', mtype: 'get', colnames: ['col id', 'first name', 'last name'], colmodel: [ { name: 'colid', index: 'colid', width: 100, align: 'left', searchoptions: { sopt: ['eq', 'ne', 'cn']} }, { name: 'firstname', index: 'firstname', width: 150, align: 'left', editable: true }, { name: 'lastname', index: 'lastname', width: 300, align: 'left', editable: true }, ], pager: jquery('#pager'), rownum: 100, rowlist: [10, 50, 100, 500, 1000, 2000, 5000, 7000, 10000], sortname: 'colid', sortorder: "asc", viewrecords: true, multiselect: true, imgpath: '/scripts/themes/steel/images', caption: 'tab master information' }).navgrid('#pager', { edit: true, add: true, del: true }, // edit options { savekey: [true, 13], reloadaftersubmit: true, jqmodal: false, closeonescape: true, closeafteredit: true, url: "/tabmaster/jqgridedit", aftersubmit: function (response, postdata) { if (response.responsetext == "success") { jquery("#success").show(); jquery("#success").html("record updated successfully! [" + postdata.firstname + " " + postdata.lastname + "]"); jquery("#success").fadeout(6000); return [true, response.responsetext] } else { return [false, response.responsetext] } } }, // add options { url: '/tabmaster/jqgridcreate', closeafteradd: true, aftersubmit: function (response, postdata) { if (response.responsetext == "success") { jquery("#success").show(); jquery("#success").html("record added successfully! [" + postdata.firstname + " " + postdata.lastname + "]"); jquery("#success").fadeout(6000); return [true, response.responsetext] } else { return [false, response.responsetext] } } }, // delete options { url: '/tabmaster/jqgridremove', aftersubmit: function (response, rowid) { if (rowid.length > 0) { jquery("#success").show(); jquery("#success").html("record deleted successfully! [" + rowid + "]"); jquery("#success").fadeout(6000); return [true, response.responsetext] } else { return [false, response.responsetext] } } }, { closeonescape: true, multiplesearch: false, closeaftersearch: true } ); });
following jquery files included in projects.
<link href="@url.content("~/content/site.css")" rel="stylesheet" type="text/css" /> <script src="@url.content("~/scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/modernizr-1.7.min.js")" type="text/javascript"></script> <link href="@url.content("~/content/themes/base/jquery.ui.theme.css")" rel="stylesheet" type="text/css" /> <link href="@url.content("~/scripts/themes/steel/grid.css")" rel="stylesheet" type="text/css" /> <link href="@url.content("~/scripts/themes/jqmodal.css")" rel="stylesheet" type="text/css" /> <script src="@url.content("~/scripts/jquery.jqgrid.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/js/jqmodal.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/js/jqdnr.js")" type="text/javascript"></script>
following hierarchy of scripts
thanks in advance! imdadhusen
it doesn't work because have hardcoded urls:
url: '/tabmaster/jqgridgetgriddata'
you should using url helpers when dealing urls:
url: '@url.action("jqgridgetgriddata", "tabmaster")'
when deploy application in virtual directory address no longer /tabmaster/jqgridgetgriddata
/yourapplicationname/tabmaster/jqgridgetgriddata
. that's reason why should use url helpers.
the same stands true edit options url , image paths. static resources use @url.content
, controller actions use @url.action
.
Comments
Post a Comment