Commit bcdca329 authored by 鲁鑫's avatar 鲁鑫

自定义显示列

parent 00b115a1
......@@ -46,6 +46,28 @@ $(document).ready(function () {
}
});
UICtrl.getColumnLocal = function(tableKey, allColumns) {
// 获取本地配置
try {
const localColumns = JSON.parse(localStorage.getItem(tableKey))
// 未读取到配置,直接返回默认columns
if (!!!localColumns) return allColumns
// 有本地配置,与默认配置进行匹配,
return allColumns.map(column => {
return {
...column,
hide: localColumns.find(v => v.name == column.name)?._hide
}
})
} catch(e) {
// 未获取到,或者报错,直接返回默认columns
return allColumns
}
}
//查询界面回车执行查询
UICtrl.initKeyDownQueryGrid = function () {
var form = $('#queryMainForm');
......@@ -806,6 +828,10 @@ UICtrl.grid = function (el, options) {
options.parms = parms;
}
var _windowWidth = $.windowWidth();
// 设置了缓存的获取缓存配置
if (options._local) {
options.columns = UICtrl.getColumnLocal(options._tableKey, options.columns)
}
$(options.columns).each(function (i, column) {
if (_windowWidth < 700) {//xx add 屏幕宽度太小不启用frozen
column['frozen'] = false;
......
......@@ -636,6 +636,17 @@ $.ligerDefaults.Grid.formatters['datetime'] = function (value, column){
this.dialog.find('.column-sort-button-div').removeClass('ui-hide');
return _height;
},
_setLocalColumns: function () {
var g = this.getGridManager();
var cols = g.columns.map(v => {
return {
name: v.name,
_hide: v._hide
}
})
// 表格显示隐藏设置缓存
localStorage.setItem(g.options._tableKey, JSON.stringify(cols))
},
_onClickEvent:function($el){
var _self = this,g = this.getGridManager();
if($el.is(':checkbox')){//字段显示&隐藏
......@@ -644,9 +655,11 @@ $.ligerDefaults.Grid.formatters['datetime'] = function (value, column){
return false;
}
g.toggleCol(parseInt($el.attr("columnindex")), $el.is(':checked'), false);
g.options._local && _self._setLocalColumns()
},10);
return false;
}
if($el.is('td')){//字段选中
if($el.parent().hasClass('disable')){
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment