Forum
15:53
12/09/2013
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.
my entire jqGrid, for reference:
$(document).ready(function () { var numberTemplate = { formatter: 'number', align: 'center', sorttype: 'number' }; jQuery("#UsersGrid").jqGrid({ url: 'Jqg.aspx/GetDataTable', datatype: 'json', mtype: 'GET', ajaxGridOptions: { contentType: "application/json", success: function (data, textStatus) { if (textStatus == "success") { var thegrid = $("#UsersGrid")[0]; thegrid.addJSONData(data.d); thegrid.grid.hDiv.loading = false; alert('success'); switch (thegrid.p.loadui) { case "disable": break; case "enable": $("#load_" + thegrid.p.id).hide(); break; case "block": $("#lui_" + thegrid.p.id).hide(); $("#load_" + thegrid.p.id).hide(); break; } } }, error: alert('failed') }, postData: { FilePath: function () { return $("#FilePath").text(); }, Filter: function () { return $("#Filter").text(); }, submenu: function () { return $("#lblSubmenu").text(); } }, mtype: 'POST', colNames: ['Sr_No', 'Errors', 'File Name', 'Date', 'action'], 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} }, { name: 'Errors', index: 'Errors', width: 100, align: 'center', search: true, sorttype: "int", sortable: true }, { name: 'File Name', index: 'files', search: true, stype: 'text', width: 500, sorttype: "string", align: 'center', sortable: true }, { name: 'Date', index: 'Date', width: 100, search: true, sortable: true, sorttype: "date", align: 'center', sorttype: 'date', formatter: 'date', formatoptions: { newformat: 'M-d-Y' }, datefmt: 'M-d-Y' }, { name: 'action', index: 'action', align: 'center', sortable: false, search: false, formatter: displayButtons}], pager: '#UsersGridPager', viewrecords: true, imgpath: 'Images/jqgrid', rowNum: 5, rowList: [5, 10, 20], gridview: true, loadonce: false, rownumbers: false, sortname: 'Sr_No', sortorder: 'desc', localReader: { id: 'Sr_No' }, editurl: 'clientArray', clickOnPagination : function() { $(this).jqGrid("clearGridData"); $(this).setGridParam({datatype: 'json'}).triggerHandler("reloadGrid"); }, cmTemplate: { searchoptions: { sopt: ['cn', 'eq', 'ne']//comment out this out tp resolve error }, searchrules: { required: true } }, height: '100%', serializeGridData: function (postData) { var propertyName, propertyValue, dataToSend = {}; for (propertyName in postData) { if (postData.hasOwnProperty(propertyName)) { propertyValue = postData[propertyName]; if ($.isFunction(propertyValue)) { dataToSend[propertyName] = propertyValue(); } else { dataToSend[propertyName] = propertyValue } } } return JSON.stringify(dataToSend); } }); jQuery("#UsersGrid").navGrid('#UsersGridPager', { add: false, edit: false, del: false, refresh: false }, {}, {}, {}, { multipleSearch: true, multipleGroup: true, afterRedraw: function () { $(this).find(".input-elm").triggerHandler('change', [true]); } }); function displayButtons(cellvalue, options, rowObject) { var View = "<a href="#" target="_blank">View</a>"; var Download = "<a href="/Download/" target="_blank">Download</a>"; return View + Download; } });
11:44
Moderators
30/10/2007
Hello,
Try first not to ovrewrite the default jqGrid ajax succes function.
The pagging, sorting and serching in your case is a server side job, so I recommend you to lookat your server side code.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
14:06
12/09/2013
tony said:
Hello,
Try first not to ovrewrite the default jqGrid ajax succes function.
The pagging, sorting and serching in your case is a server side job, so I recommend you to lookat your server side code.
Regards
Thank you tony
Here is my server code
public static s_GridResult GetDataTable(string _search, string nd, int rows, int page, string sidx,
string sord, string FilePath, string Filter, string submenu) { int startindex = (page - 1); int endindex = page; DataTable dt = xxxxxxxx;//returns datatable s_GridResult result = new s_GridResult(); List<s_RowData> rowsadded = new List<s_RowData>(); int idx = 1; foreach (DataRow row in dt.Rows) { s_RowData newrow = new s_RowData(); newrow.id = idx++; newrow.cell = new string[4]; //total number of columns newrow.cell[0] = row[0].ToString(); newrow.cell[1] = row[1].ToString(); newrow.cell[2] = row[2].ToString(); newrow.cell[3] = row[4].ToString(); rowsadded.Add(newrow); } result.rows = rowsadded.ToArray(); result.page = page; result.total = dt.Rows.Count; result.record = rowsadded.Count; return result; }
Plzz Help me
14:07
12/09/2013
sarvani said:
tony said:
Hello,
Try first not to ovrewrite the default jqGrid ajax succes function.
The pagging, sorting and serching in your case is a server side job, so I recommend you to lookat your server side code.
Regards
Thank you tony
Here is my server code
public static s_GridResult GetDataTable(string _search, string nd, int rows, int page, string sidx,string sord, string FilePath, string Filter, string submenu) { int startindex = (page - 1); int endindex = page; DataTable dt = xxxxxxxx;//returns datatable s_GridResult result = new s_GridResult(); List<s_RowData> rowsadded = new List<s_RowData>(); int idx = 1; foreach (DataRow row in dt.Rows) { s_RowData newrow = new s_RowData(); newrow.id = idx++; newrow.cell = new string[4]; //total number of columns newrow.cell[0] = row[0].ToString(); newrow.cell[1] = row[1].ToString(); newrow.cell[2] = row[2].ToString(); newrow.cell[3] = row[4].ToString(); rowsadded.Add(newrow); } result.rows = rowsadded.ToArray(); result.page = page; result.total = dt.Rows.Count; result.record = rowsadded.Count; return result; }Plzz Help mei'm new to jqgrid...:(
11:48
Moderators
30/10/2007
Hello,
It seems to me you do not read my post carfully.
Please read it again. TRY TO USE A VERY SIMPLE JQGRID SETUP AS FROM THE DEMOS.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
11:09
28/11/2013
Tony,
I am also getting same problem. Search and paging are not working for the JSON.
I am using simple grid.
Please see the following code.
</script> }); $("##list").jqGrid('navGrid','##pager',{add:false,edit:false,del:false}); }); } id: "id" cell: "", total: "TOTAL", page: "PAGE", root: "ROWS", jsonReader: { caption: "#rc.grid#", viewrecords: true, sortorder: "desc", rowList:[10,20,30], rowNum:10, }, $("##"+subgrid_table_id).jqGrid('navGrid',"##"+pager_id,{edit:false,add:false,del:false}) }); jsonReader: { repeatitems : false, root:"attribute" } width: '100%', height: '100%', autowidth: "true", // sortorder: "asc", // sortname: 'VOL1', //pager: pager_id, pager: $("##"+pager_id), viewrecords: true, rowList:[10,20,30], rowNum:10, ], {name:"PAID_RANK",index:"PAID_RANK",align:"center"} {name:"STATUS",index:"STATUS",align:"center"}, {name:"VOL1",index:"VOL1",align:"center",formatter:'number',formatoptions:{decimalPlaces:0,thousandsSeparator:""}}, {name:"LEVEL",index:"LEVEL",align:"center"}, {name:"NAME",index:"NAME",align:"left"}, {name:"DIST_ID",index:"DIST_ID",align:"center",key:true}, colModel: [ colNames: ['DIST_ID','NAME','LEVEL','VOL1','STATUS','PAID_RANK'], datatype: 'json', url:"index.cfm?event=Hierarchical_Grid.viewHierarchical_SubGrid&id="+row_id+"&distID="+distID+"&DTS_Detail="+DTS_Detail, $("##"+subgrid_table_id).jqGrid({ $("##"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>"); DTS_Detail=$("##client option:selected").val(); distID=$("##list").getCell(row_id,'DIST_ID'); //alert(pager_id); //alert(orderid); //var orderid = rowdata.DIST_ID; //var rowdata = jQuery('##list').getRowData(row_id); pager_id="p_"+subgrid_table_id; subgrid_table_id = subgrid_id+"_t"; var distID,DTS_Detail; var pager_id; var subgrid_table_id,pager_id,distID; subGridRowExpanded: function(subgrid_id, row_id) { }, "selectOnExpand": true // select the row when the expand column is clicked "reloadOnExpand": false, // load the subgrid data only once and the just show/hide "openicon": "ui-icon-arrowreturn-1-e", "minusicon": "ui-icon-triangle-1-s", "plusicon": "ui-icon-triangle-1-e", subGridOptions: { // define the icons in subgrid subGrid: true, pager: $('##pager'), width: 1100, height: "auto", loadui: "enable", {name:'PAID_RANK',index:'PAID_RANK',align:"center",sorttype:"int"}], {name:'VOL3',index:'VOL3',align:"center",sorttype:"int",formatter:'number',formatoptions:{decimalPlaces:0,thousandsSeparator:""}}, {name:'NAME',index:'NAME',align:"left",sorttype:"string"}, {name:'DIST_ID',index:'DIST_ID',align:"center",sorttype:"int"}, colModel:[ colNames:['DIST_ID','NAME','VOL3','PAID_RANK'], datatype: 'local', data: #SerializeJSON(prc.griddata)#, $("##list").jqGrid({ $(document).ready(function(){<script type="text/javascript">
Most Users Ever Online: 715
Currently Online:
25 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66