1. 程式人生 > >jquery easyui裏datagrid用法記錄

jquery easyui裏datagrid用法記錄

action 名稱 lap pre election soft 未定義 enter table

1、刪除行方法(deleteRow

$(#ruleManagementTable).datagrid(deleteRow, 1); 
//1代表選中的行索引

2、刪除多行數據

var rows = $(#ruleManagementTable).datagrid("getSelections"); //獲取你選擇的所有行
//循環所選的行
for(var i =0,l=rows.length;i<l;i++){
    var index = $(#ruleManagementTable).datagrid(getRowIndex,rows[i]);//獲取某行的行號
    $(
#ruleManagementTable).datagrid(deleteRow,index); //通過行號移除該行
}

註意:(1)var rows = $(#ruleManagementTable‘).datagrid("getSelections"); //獲取你選擇的所有行,返回的是一個數組,數組裏面是各行對象

   (2)var index = $(#ruleManagementTable‘).datagrid(getRowIndex‘,rows[i]);//獲取某行的行號,由於rows是一個數組,所以必須以rows[i]的形式,否則是獲取不到行號的,獲取不到就是 -1;如果row已經過濾了只有一個,那麽就寫成 rows[0] 。

3、插入行insertRow

// 在第二行的位置插入一個新行
//index:要插入的行索引,如果該索引值未定義,則追加新行。
//row:行數據。
$(#dg).datagrid(insertRow,{
    index: 1,  // 索引從0開始
    row: {
        name: 新名稱,
        age: 30,
        note: 新消息
    }
});
//新建規則庫表
getDeskTopObj().$(#ruleManagementTable).datagrid(insertRow,{
    index:0,
    row: {
        softId : jsondata.softId,
        softName : jsondata.softName,
        genRightRule : jsondata.genRightRule,
        unGenRightRule : jsondata.unGenRightRule
    }
});

4、重新加載,並遠程傳入參數

$("#inside_tableElement").datagrid("load",{
   "genuineSerialNumberManagement.type":type,
   "genuineSerialNumberManagement.softDisplayName":softDisplayName
});

5、初始化的時候遠程傳入參數 queryParams

//正版序列號庫列表
var type = $("input[name=‘serialNumber‘]:checked").val();
$("#inside_tableElement").datagrid({
    striped : true,
    collapsible : true,
    height:500,
    url : "${basePath}/genuineSerialNumberManagementAction_list.do",
    queryParams:{
        "genuineSerialNumberManagement.type":type
    },
    columns : [ [ 
        {field : softDisplayName,title : 軟件名,align : center,width : (datag_width * 0.44)}, 
        {field : version,title : 版本號,align : center,width : (datag_width * 0.44)}, 
        {field : serialNumber,title : 序列號,align : center,width : (datag_width * 0.44)}
    ] ],
    fitColumns : true,
    rownumbers : true,
    pagination:true,
    pageSize: 20,
    pageList: [20, 50, 100],
    onSelectAll : function() {
    },
    onUnselectAll : function() {
    },
    onSelect : function() {
    },
    onUnselect : function(rowIndex, rowData) {
    }
});

6、

jquery easyui裏datagrid用法記錄