var resultType;
$(function() {
$.ajax({
type: 'POST',
url: '/dic?type=serverType',
success: function (result) {
resultType = result;
}
});
datagrid = $('#datagrid').datagrid({
url : 'url',
title : '',
iconCls : 'icon-save',
fit : true,
fitColumns : true,
nowrap : false,
border : true,
idField : 'id', //指明哪一個字段是標識字段
singleSelect : false, //單選
pagination : true, //分頁
rownumbers: true, //序列號
scrollbarSize :1,
toolbar: "#gridtoolbar",
columns : [ [
{
title : 'ID',
field : 'id',
width : '10%',
checkbox : true
},
{
title : '所屬系統',
field : 'resultType',
sortable : true,
width : '20%',
formatter: function (value, row, index) {
for (i in resultType) {
if (serverType[i].code == value){
return serverType[i].code+'('+serverType[i].name+')';
}
}
}
}
] ],
onClickRow:function(rowIndex,rowData){
$(this).datagrid('unselectAll');
$(this).datagrid('selectRow',rowIndex);
},
onLoadSuccess : function(data) {
//一定要加上這一句,要不然datagrid會記住之前的選擇狀態,刪除時會出問題
$('#datagrid').datagrid('clearSelections');
}
}
通過頁面的url:'/test/view'加載例如上面的頁面,datagrid加載在多次重複點擊頁面的時候,formatter函數麼有顯示出來,
例如:
正常情況下應該是
時好時壞
解決辦法:未解決