Saturday, 15 January 2011

javascript - jqgrid rowobject value is undefined -



javascript - jqgrid rowobject value is undefined -

i utilize next code bind values in jqgrid.

and create 1 link button access particular action method.

i need pass firstcolumn value action method.

but ,if utilize next href='@url.action("viewapplicants", "hr")?jobsid="+rowobject[0]+" '.it show undefined value .how solve this?

<div> <table id="jobtable"></table> <div id="jqgridpager"></div> <div id="dialog" title="view job detail"></div> </div> <script type="text/javascript"> $(document).ready(function () { $("#jobtable").jqgrid({ url: '/hr/passjsonjob/', datatype: "json", mtype: 'get', colnames: ['job id', 'job title', 'job experience', 'job location', 'viewapplicants'], colmodel: [ { name: 'jobsid', index: 'jobsid', width: 150, align: 'left', editable: true }, { name: 'jobtitle', index: 'jobtitle', width: 150, align: 'left', editable: true }, { name: 'jobexperience', index: 'jobexperience', width: 150, align: 'left', editable: true }, { name: 'joblocation', index: 'joblocation', width: 150, align: 'left', editable: true }, { name: 'viewapplicants', index: 'viewapplicants', width: 150, sortable: false, formatter: function (cellvalue, options, rowobject) { alert(rowobject) homecoming "<a href='@url.action("viewapplicants", "hr")?jobsid="+rowobject[0]+"'>view applicants</a>"; } } ], rownum: 10, rowlist: [10, 20, 30], viewrecords: true, loadonce: true, gridview: true, pager: "#jqgridpager", celledit: false, rownumbers: true, width: 1000, caption: 'applied jobs', viewrecords: true }) $('#jobtable').jqgrid('navgrid', '#jqgridpager', { edit: true, add: false, del: false, view: false, search: false }); }); </script>

it's of import know format of server response url /hr/passjsonjob/. format of rowobject corresponds format of items server response. rowobject.jobsid instead of rowobject[0] right way access jobsid property. because utilize loadonce: true format of rowobject rowobject[0] at first load. later, example, @ local paging or sorting of data, format of rowobject object jobsid property, rowobject.jobsid correct.

so usage of rowobject.jobsid or rowobject[0] || rowobject.jobsid prepare problem.

one more alternative utilize property key: true in definition of jobsid column in colmodel. 1 can utilize property if jobsid contains unique values in every row. in case jqgrid utilize value jobsid column rowid: value of id attribute assigned rows (<tr> elements) of grid. in case 1 utilize options.rowid access jobsid value.

javascript jquery asp.net-mvc-4 jqgrid

No comments:

Post a Comment