Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
jqgrid json object paging & searching not working
12/09/2013
15:53
Avatar
sarvani
Member
Members
Forum Posts: 6
Member Since:
12/09/2013
sp_UserOfflineSmall Offline

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; } });
13/09/2013
11:44
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

13/09/2013
14:06
Avatar
sarvani
Member
Members
Forum Posts: 6
Member Since:
12/09/2013
sp_UserOfflineSmall Offline

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 Frown
13/09/2013
14:07
Avatar
sarvani
Member
Members
Forum Posts: 6
Member Since:
12/09/2013
sp_UserOfflineSmall Offline

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 me

i'm new to jqgrid...:(

18/09/2013
20:24
Avatar
sarvani
Member
Members
Forum Posts: 6
Member Since:
12/09/2013
sp_UserOfflineSmall Offline

help me

19/09/2013
11:48
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

29/11/2013
11:09
Avatar
cfexpert
New Member
Members
Forum Posts: 1
Member Since:
28/11/2013
sp_UserOfflineSmall Offline

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">

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
35 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information