jqgrid定义多选操作
生活随笔
收集整理的這篇文章主要介紹了
jqgrid定义多选操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
先定義:? ? var SelectRowIndx;
然后加入以下屬性:
multiselect: true,onSelectRow: function () {SelectRowIndx = GetJqGridRowIndx("#" + this.id);},gridComplete: function () {$("#" + this.id).jqGrid('setSelection', SelectRowIndx);}舉例:
<script type="text/javascript">$(function () {GetGrid();})//加載表格function GetGrid() {var SelectRowIndx;$("#gridTable").jqGrid({url: "@Url.Content("~/School/ClassInfoes/GridPageListJson")",datatype: "json",height: $(window).height() - 149,autowidth: true,colModel: [{ label: 'Id', name: 'id', index: 'id', width: 0, align: 'left', sortable: true, hidden: true },{ label: '所屬學校', name: 'schoolname', index: 'schoolname', width: 120, align: 'center', sortable: true },{ label: '班級編碼', name: 'classcode', index: 'classcode', width: 70, align: 'center', sortable: true },{ label: '院系部', name: 'departname', index: 'departname', width: 50, align: 'center', sortable: true },{ label: '入學年份', name: 'enteryear', index: 'enteryear', width: 50, align: 'center', sortable: true },{ label: '畢業年份', name: 'graduateyear', index: 'graduateyear', width: 50, align: 'center', sortable: true },{ label: '當前所在年級', name: 'currentgradename', index: 'currentgradename', width: 50, align: 'center', sortable: true },{ label: '當前所屬班級', name: 'currentclassname', index: 'currentclassname', width: 50, align: 'center', sortable: true },{ label: '班級教室', name: 'classroom', index: 'classroom', width: 50, align: 'center', sortable: true },{ label: '畢業年級', name: 'graduategradename', index: 'graduategradename', width: 50, align: 'center', sortable: true },{ label: '班主任', name: 'classteachername', index: 'classteachername', width: 50, align: 'center', sortable: true },{ label: '班長', name: 'monitername', index: 'monitername', width: 50, align: 'center', sortable: true },{label: '是否畢業', name: 'flaggraduate', index: 'flaggraduate', width: 50, align: 'center', sortable: true,formatter: function (cellvalue, options, rowObject) {if (cellvalue == true) return "<font color='red'>是</font>";if (cellvalue == false) return "<font color='green'>否</font>";}},{label: '創建日期', name: 'createdate', index: 'createdate', width: 100, align: 'center', sortable: true,formatter: function (cellvalue, options, rowObject) {return formatDate(cellvalue, 'yyyy-MM-dd');}},{ label: '創建者', name: 'createusername', index: 'createusername', width: 50, align: 'center', sortable: true },{label: '修改日期', name: 'modifydate', index: 'modifydate', width: 100, align: 'center', sortable: true,formatter: function (cellvalue, options, rowObject) {return formatDate(cellvalue, 'yyyy-MM-dd');}},{ label: '修改者', name: 'modifyusername', index: 'modifyusername', width: 50, align: 'center', sortable: true },{label: '學生列表', name: 'id', index: 'id', width: 80, align: "center", sortable: false,formatter: function (cellvalue, options, rowObject) {var id = rowObject['id'] return "<button οnclick=\"AddTabMenu('530b9428-25d9-4166-9dc2-ea994b90cdd6', '/School/Students/StudentsList?id=" + id + "', '學生管理', 'group.png','true',true)\"> 點擊我</button>";}},],pager: "#gridPager",sortname: 'classcode',sortorder: 'asc',rownumbers: true,shrinkToFit: false,gridview: true,multiselect: true,onSelectRow: function () {SelectRowIndx = GetJqGridRowIndx("#" + this.id);},gridComplete: function () {$("#" + this.id).jqGrid('setSelection', SelectRowIndx);}}); }//新增function btn_add() {var url = "/School/ClassInfoes/Form";openDialog(url, "Form", "新增班級數據表", 770, 395, function (iframe) {top.frames[iframe].AcceptClick();});}//編輯function btn_edit() {var KeyValue = GetJqGridRowValue("#gridTable", "id");if (IsChecked(KeyValue)) {var url = "/School/ClassInfoes/Form?KeyValue=" + KeyValue;openDialog(url, "Form", "編輯班級數據表", 770, 395, function (iframe) {top.frames[iframe].AcceptClick();});}}//批量添加班級function btn_autoadd() {var url = "/School/ClassInfoes/AutoAddClassInfoes";openDialog(url, "AutoAddClassInfo", "批量添加班級", 770, 395, function (iframe) {top.frames[iframe].AcceptClick();});}//刪除function btn_delete() {var KeyValue = GetJqGridRowValue("#gridTable", "id");if (IsDelData(KeyValue)) {var delparm = 'KeyValue=' + KeyValue;delConfig('/School/ClassInfoes/DeleteClassInfoes', delparm, KeyValue.split(",").length);}}//明細function btn_detail() {var KeyValue = GetJqGridRowValue("#gridTable", "id");if (IsChecked(KeyValue)) {var url = "/School/ClassInfoes/Detail?KeyValue=" + KeyValue;Dialog(url, "Detail", "班級數據表明細", 820, 500, function (iframe) {top.frames[iframe].AcceptClick();});}}//刷新function windowload() {$("#gridTable").trigger("reloadGrid"); //重新載入 } </script>?
轉載于:https://www.cnblogs.com/yechangzhong-826217795/p/5607037.html
總結
以上是生活随笔為你收集整理的jqgrid定义多选操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 直接用img 的src属性显示base6
- 下一篇: Alpha版本总结