I want to search for text in SharePoint List by entering text to be searched in the textbox. I have a webservice and I am get json response from it. My response looks like
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{ "total":2, "page":1, "records":6, "rows": [{"ID":"1","Title":"1","Desc":"one"}, {"ID":"2","Title":"2","Desc":"two"}, {"ID":"3","Title":"3","Desc":"three"}, {"ID":"4","Title":"4","Desc":"four"}, {"ID":"5","Title":"5","Desc":"five"}, {"ID":"6","Title":"6","Desc":"six"} ]} |
My javascript looks like this
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 |
function GridSearchText() { $('#Tracking').GridUnload(); var text = $('#txttext').val().trim(); //my text to be searched $("#Tracking").jqGrid({ prmNames: { search: "isSearch", nd: null, rows: "numRows", page: "page", sort: "sortField", order: "sortOrder" }, postData: { PO_txt: text }, datatype: function (postdata) { $("#load_Tracking").show(); $.ajax({ url: "DataSources.aspx/GridText", data: JSON.stringify(postdata), type: "POST", contentType: "application/json", dataType: "JSON", success: function (data, st) { if (st == "success") { var grid = $("#Tracking"); var gridData = JSON.parse(data.d); grid.clearGridData(); if (gridData.rows.length > 0) { for (var i = 0; i < gridData.rows.length; i++) { row = gridData.rows<em class="d4pbbc-italic"></em>; grid.addRowData(i + 1, row); $("#load_PRTracking").hide(); } } else { $('.ui-jqgrid').hide(); alert("Text does not exist. No records to display."); } } }, error: function (data, textStatus) { $("#load_PRTracking").hide(); alert('Error loading Grid'); } }); }, autowidth: true, height: "500px", colNames: ["ID", "Title", "Desc"], colModel: [ { name: "ID", align: 'center', width: "1500px" }, { name: "Title", align: 'center', width: "2000px", sortable: false }, { name: "Desc", align: 'center', width: "1500px", sortable: false }, ], jsonReader: { root: "rows", page: "page", total: "total", records: "records", id: "ID", //index of the column with the PK in it repeatitems: false }, shrinktofit: true, rowNum: 3, rowList: [3, 6], pager: '#TrackingPager', sortname: "Title", sortorder: "asc", viewrecords: true, gridview: true, autoencode: true, loadonce: true, pgtext: "Page {0} of {1}", loadtext: "Searching Text ...!!!" }); $("#Tracking").jqGrid('gridResize', '#TrackingPager'); } |
I get the data on the grid but the pagination shows Page 1 of 0. Please help me in getting the pagination right.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top