EasyUi DataGrid、TreeGrid單元格點選事件
阿新 • • 發佈:2019-02-08
1、EasyUi DataGrid單元格點選事件
//裝置供應商列表
var devSupplierInfoDataGrid = $('#devSupplierInfoDataGrid').datagrid({
url : "/dev/supplier/supplier/queryList.do",
fit : true,
fitColumns : false,
border : false,
pagination : true,
idField : 'id',
/* textField : 'name', */
/* sortName : 'date',
sortOrder : 'asc', */
rownumbers: true,
remoteSort: false,
pageSize : 20,
pageList : [ 20, 30, 50, 100 ],
singleSelect : true,
checkOnSelect : true,
selectOnCheck : true,
nowrap : false,
showPageList:false,
frozenColumns : [ [ {
field : 'id',
title : 'id',
hidden : true
}, {
field : 'name',
title : '名稱',
align:'center',
width : 180,
formatter:function(value,row,index){
if(row == null){
return "";
}
value = row.name;
return linkValueFormatter(value,row,index);
}
}
] ],
toolbar : '#devSupplierInfoDataGridToolbar' ,
onLoadSuccess : function() {
$(this).datagrid('clearChecked');
$(this).datagrid('clearSelections');
},
//單元格點選事件
onClickCell:function(rowIndex, field, value){
if(field == 'name'){
var rows = $('#devSupplierInfoDataGrid').datagrid('getRows');
//獲取點選的行
var row = rows[rowIndex];
//檢視裝置供應商資訊
showDevSupplierInfo(row.id);
}
}
});
showDevSupplierInfo函式:
//檢視裝置供應商資訊
function showDevSupplierInfo(id) {
var url = "/dev/supplier/supplier/toEditJsp.do?id=" + id;
var obj = {
area: ['100%', '100%'],
url : url,
title : '檢視裝置供應商資訊',
width : '770px',
height : '548px',
id : 'supplierView'
};
window.XZhi.getDialogPage(2, obj);
}
2、EasyUi TreeGrid單元格點選事件
//裝置型別TreeGrid
var devTypeTreeGrid = $('#devTypeTreeGrid').treegrid({
url : "/dev/base/type/queryList.do",
fit : true,
fitColumns : false,
border : false,
idField : 'id',
treeField : 'name',
parentField : 'pid',
remoteSort: false,
rownumbers:true,
singleSelect:true,
checkOnSelect : true,
selectOnCheck : true,
nowrap : true,
showPageList:false,
columns : [ [ {
field : 'name',
title : '型別名稱',
width : 260,
align:'left',
sortable: true,
formatter:function(value,row,index){
if(row == null){
return "";
}
value = row.code;
return linkValueFormatter(value,row,index);
}
},{
field : 'code',
title : '編號',
width : 100,
align:'center',
sortable: true
},{
field : 'order',
title : '排序',
width : 100,
align:'center',
sortable: true
},{
field : 'createName',
title : '建立人',
align:'center',
width : 100,
sortable: true,
formatter:function(value,row,index){
if(row.createUser == null){
return "";
}
return row.createUser.name;
}
},{
field : 'createDate',
title : '建立日期',
align:'center',
width : 100,
sortable: true,
formatter: function (value, row, index) {
return getDate(value);
}
}
]],
toolbar : '#devTypeTreeGridToolbar',
onLoadSuccess : function(row,data) {
$(this).treegrid('clearChecked');
$(this).treegrid('clearSelections');
},
onSelect : function(rowIndex, rowData){
}
,
loadFilter: function (data, parent) {
var opt = $(this).data().treegrid.options;
return treeFilter(data, opt);
},
//單元格點選事件
onClickCell:function(field, row){
if(field == 'name'){
//檢視裝置型別資訊
showDevTypeInfo(row.id);
}
}
});
showDevTypeInfo函式:
//檢視裝置型別資訊
function showDevTypeInfo(id){
var url = "/dev/base/type/toEditJsp.do?id="+id+"&editType=0";
var obj = {
area: ['100%', '100%'],
url: url,
title: '檢視裝置型別',
width : '770px',
height : '280px',
id : 'devTypeVie'
};
window.XZhi.getDialogPage(2, obj);
}