|
1 |
Hi i'm using jqgrid and json object.i'm getting the data but paging and search not working..means when i click on next page same data is appearing and in search too..plzzz help me. |
|
1 |
<br /> |
|
1 |
<pre class="default prettyprint prettyprinted"><div class="sfcode">my entire jqGrid, for reference:</div> |
|
1 |
<br /> |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
<div class="sfcode">$(document).ready(function () {<br /> var numberTemplate = { formatter: 'number', align: 'center', sorttype: 'number' };<br /> jQuery("#UsersGrid").jqGrid({<br /> url: 'Jqg.aspx/GetDataTable',<br /> datatype: 'json',<br /> mtype: 'GET',<br /> ajaxGridOptions: { contentType: "application/json",<br /> success: function (data, textStatus) {<br /> if (textStatus == "success") {<br /> var thegrid = $("#UsersGrid")[0];<br /> thegrid.addJSONData(data.d);<br /> thegrid.grid.hDiv.loading = false; alert('success');<br /> switch (thegrid.p.loadui) {<br /> case "disable":<br /> break;<br /> case "enable":<br /> $("#load_" + thegrid.p.id).hide();<br /> break;<br /> case "block":<br /> $("#lui_" + thegrid.p.id).hide();<br /> $("#load_" + thegrid.p.id).hide();<br /> break;<br /> }<br /> }<br /> },<br /> error: alert('failed')<br /> },<br /> <br /> postData: {<br /> FilePath: function () {<br /> return $("#FilePath").text();<br /> },<br /> Filter: function () {<br /> return $("#Filter").text();<br /> },<br /> submenu: function () {<br /> return $("#lblSubmenu").text();<br /> }<br /> },<br /> mtype: 'POST',<br /> colNames: ['Sr_No', 'Errors', 'File Name', 'Date', 'action'],<br /> colModel: [{ name: 'Sr_No', index: 'Sr_No', key: true, width: 100, align: 'center', sortable: true, sorttype: 'integer', searchtype: "integer", searchrules: { "required": true, "number": true, "maxValue": 13} },<br /> { name: 'Errors', index: 'Errors', width: 100, align: 'center', search: true, sorttype: "int", sortable: true },<br /> { name: 'File Name', index: 'files', search: true, stype: 'text', width: 500, sorttype: "string", align: 'center', sortable: true },<br /> { name: 'Date', index: 'Date', width: 100, search: true, sortable: true, sorttype: "date", align: 'center', sorttype: 'date',<br /> formatter: 'date', formatoptions: { newformat: 'M-d-Y' }, datefmt: 'M-d-Y'<br /> },<br /> { name: 'action', index: 'action', align: 'center', sortable: false, search: false, formatter: displayButtons}],<br /> pager: '#UsersGridPager',<br /> viewrecords: true,<br /> imgpath: 'Images/jqgrid',<br /> rowNum: 5,<br /> rowList: [5, 10, 20],<br /> gridview: true,<br /> loadonce: false,<br /> rownumbers: false,<br /> sortname: 'Sr_No',<br /> sortorder: 'desc',<br /> localReader: { id: 'Sr_No' },<br /> editurl: 'clientArray',<br /> clickOnPagination : function() { $(this).jqGrid("clearGridData"); $(this).setGridParam({datatype: 'json'}).triggerHandler("reloadGrid"); },<br /> cmTemplate: {<br /> searchoptions: {<br /> sopt: ['cn', 'eq', 'ne']//comment out this out tp resolve error<br /> },<br /> searchrules: {<br /> required: true<br /> }<br /> },<br /> height: '100%',<br /> serializeGridData: function (postData) {<br /> var propertyName, propertyValue, dataToSend = {};<br /> for (propertyName in postData) {<br /> if (postData.hasOwnProperty(propertyName)) {<br /> propertyValue = postData[propertyName];<br /> if ($.isFunction(propertyValue)) {<br /> dataToSend[propertyName] = propertyValue();<br /> } else {<br /> dataToSend[propertyName] = propertyValue<br /> }<br /> }<br /> }<br /> <br /> return JSON.stringify(dataToSend);<br /> }<br /> });<br /> jQuery("#UsersGrid").navGrid('#UsersGridPager',<br /> { add: false, edit: false, del: false, refresh: false },<br /> {},<br /> {},<br /> {},<br /> { multipleSearch: true, multipleGroup: true, afterRedraw: function () {<br /> $(this).find(".input-elm").triggerHandler('change', [true]);<br /> }<br /> });<br /> function displayButtons(cellvalue, options, rowObject) {<br /> var View = "<a href="#" target="_blank" rel="nofollow">View</a>";<br /> var Download = "<a href="/Download/" target="_blank" rel="nofollow">Download</a>";<br /> return View + Download;<br /> }<br /> });</div> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top