jquery - why jqgrid not calling my method -
i trying start jqgrid sample.i dont know whats wrong in code doent work.ofcourse no errors well. not calling method retrive data. using mvc2. search.aspx:
<script src="/scripts/jquery.jqgrid.min.js" type="text/javascript"></script> <script type="text/javascript"> var lastsel; $(document).ready(function() { $('#jqgcustomers').jqgrid({ //url wich data should requested url: '/home/customersgriddata/', //type of data datatype: 'json', //url access method type mtype: 'get', //columns names colnames: ['customernumber', 'prename', 'firstname', 'lastname', 'gender', 'modified date'], //columns model colmodel: [ { name: 'customer_number', index: 'customer_number', align: 'left', width: 85, editable: false }, { name: 'pre_name', index: 'pre_name', align: 'left', width: 200, editable: true, edittype: 'text', editoptions: { maxlength: 40 }, editrules: { required: true} }, { name: 'first_name', index: 'first_name', align: 'left', width: 225, formatter: supplierformatter, unformat: supplierunformatter, editable: true, edittype: 'select', editoptions: { dataurl: '/home/suppliersselect' }, editrules: { required: true} }, { name: 'last_name', index: 'last_name', align: 'left', width: 140, editable: true, edittype: 'select', editoptions: { dataurl: '/home/categoriesselect' }, editrules: { required: true} }, { name: 'gender', index: 'gender', align: 'left', editable: true, edittype: 'text', editoptions: { maxlength: 20 }, editrules: { required: true} }, { name: 'last_modified', index: 'last_modified', align: 'left', formatter: 'currency', formatoptions: { decimalseparator: '.', thousandsseparator: ',', decimalplaces: 2, prefix: '$' }, editable: true, edittype: 'text', editrules: { required: true, number: true, minvalue: 0} }, ], //pager grid pager: $('#jqgcustomers'), //number of rows per page rownum: 10, //initial sorting column sortname: 'customer_number', //initial sorting direction sortorder: 'asc', //we want display total records count viewrecords: true, //grid width width: 'auto', //grid height height: 'auto' }); $('#jqdlgcustomers').dialog({ autoopen: false, bgiframe: true, resizable: false, title: 'customer' }); }); function supplierformatter(cellvalue, options, rowobject) { return "<a href='' onclick='showsupplierdialog(this, " + cellvalue.substr(1, cellvalue.indexof(']') - 1) + "); return false;'>" + cellvalue.substr(cellvalue.indexof(']') + 2) + "</a>"; }; function supplierunformatter(cellvalue, options, cellobject) { return cellvalue; } </script> homecontrollers.cs:
[httpget] public actionresult customersgriddata(string sidx, string sord, int page, int rows) { //getting total records count repository int totalrecords = _repository.getcustomercount(); //preparing anonymous variable json data var customerdata = new { //total pages count total = (int)math.ceiling((float)totalrecords / (float)rows), //page number page = page, //total records count records = totalrecords, //table rows data rows = (from customer in _repository.getcustomers(string.empty, sidx, sord, page - 1, rows) select new { id = customer.customer_number, cell = new string[] { customer.customer_number, customer.first_name, customer.pre_name, customer.last_name, customer.gender != null ? convert.tostring(customer.gender):null, convert.tostring(customer.last_modified) } }).toarray() }; return json(customerdata, jsonrequestbehavior.allowget); } is because of jqgrid url?
Comments
Post a Comment