Last active
January 10, 2018 02:58
-
-
Save jay61439476/260710b0a7d2016e3487 to your computer and use it in GitHub Desktop.
jqGrid常用方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//分页情况下获取全部数据 | |
var allRowsInGrid = $('#list4').jqGrid('getGridParam','data'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localReader: { | |
id: "row_id" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function searchGridFn() { | |
grid = $("#myGrid"); | |
var searchFiler = $("#filter").val(), f; | |
if (searchFiler.length === 0) { | |
grid[0].p.search = false; | |
$.extend(grid[0].p.postData, { filters: "" }); | |
} | |
f = { groupOp: "OR", rules: [] }; | |
f.rules.push({ field: "name", op: "cn", data: searchFiler }); | |
f.rules.push({ field: "delCol", op: "cn", data: searchFiler }); | |
grid[0].p.search = true; | |
$.extend(grid[0].p.postData, { filters: JSON.stringify(f) }); | |
grid.trigger("reloadGrid", [{ page: 1, current: true}]); | |
} | |
</script> | |
<input id="filter" /> | |
<button id="searchButton" onclick="searchGridFn()">Search</button> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#sp_1").text(); // total pages | |
$(".ui-pg-input").val(); // current page | |
$('#your_grid').getGridParam('page'); // current page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//You can examine the values of the jqGrid parameters sortname and sortorder ("desc" or "asc"). To get the parameters you can use getGridParam method: | |
var sortColumnName = $("#list").jqGrid('getGridParam','sortname'); | |
//and | |
var sortOrder = $("#list").jqGrid('getGridParam','sortorder'); // 'desc' or 'asc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var allRowsIdsOnCurrentPage = $('#file-grid').jqGrid('getDataIDs'); | |
var allRowsOnCurrentPage = $('#file-grid').jqGrid('getRowData'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#myGrid').getGridParam("postData").filters; | |
$('#myGrid').jqGrid('getGridParam', "postData").filters; | |
//will give you a string | |
// "{"groupOp":"AND","rules":[{"field":"Name","op":"bw","data":"a"}]}" | |
//rules have the search criteria. If i have multiple search criteria, all would be there | |
// "{"groupOp":"AND","rules":[{"field":"Name","op":"bw","data":"a"},{"field":"Description","op":"bw","data":"d"}]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#uiGrid1').trigger("reloadGrid",[{page:5}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//取消选中 | |
$('#grid').jqGrid('resetSelection'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select all row | |
var $grid = $("#Grid"); | |
$grid.jqGrid('resetSelection'); | |
var ids = $grid.getDataIDs(); | |
for (var i=0, il=ids.length; i < il; i++) { | |
$grid.jqGrid('setSelection',ids[i], false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i, count, $grid = $("#myTable"); | |
for (i = 0, count = rowArray.length; i < count; i += 1) { | |
$grid.jqGrid('setSelection', rowArray[i], false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.jgrid.ajaxOptions.type = 'post'; | |
//这样可以避免中文查询参数乱码 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 修改tomcat的server.xml,增加useBodyEncodingForURI="true" --> | |
<Connector port="8080" protocol="HTTP/1.1" | |
connectionTimeout="20000" | |
redirectPort="8443" useBodyEncodingForURI="true" /> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment