ext-all.js在显示/隐藏网格列时没有响应
题
我遇到了一个问题,其中ext-all.js文件在尝试显示/隐藏网格列时挂起。
我正在使用Mozilla Firefox 25.0上的Extjs 4.1.2。OS是Ubuntu 12.10,只是为了澄清。
当用户通过插件编辑行时,隐藏的字段仅显示为才能显示,以便用户可以编辑它们。编辑完成后,这些列再次隐藏。
controller.js:
var hiddenColumns = []; //global array for storing columns
init: function() {
this.control({
...
'myGrid': {
beforeedit: function() {
me.columnsVisibility('show');
},
afterrender: function(){
var me = this,
formDataPanel = me.getFormDataPanel(),
activeGrid = formDataPanel.getLayout().getActiveItem();
for (i=0; i < activeGrid.columns.length; i++) {
if (activeGrid.columns[i].hidden) {
Ext.Array.push(hiddenColumns, activeGrid.columns[i]);
}
}
},
edit: function(editor, e) {
var me = this,
usersStore = me.getStore('Users'),
alias = me.getUserAlias(),
record = usersStore.findRecord('email', alias, false, true, true),
fdupdate = record.get('fdupdate');
me.columnsVisibility('hide');
if (fdupdate == 't') {
try {
e.store.sync();
}
catch (e) { }
e.record.commit();
} else {
var store = me.getStore('Inspection');
store.rejectChanges();
Ext.Msg.alert('Alert!','This function is not currently available for you');
}
},
...
}
});
},
...
columnsVisibility: function(visible){
for (var i=0; i < hiddenColumns.length; i++) {
if (visible == 'hide') {
hiddenColumns[i].hide();
} else if (visible == 'show') {
hiddenColumns[i].show();
}
}
},
...
.
mygrid.js:
initComponent: function() {
var filters = {
ftype: 'filters',
// encode and local configuration options defined previously for easier reuse
encode: false, // json encode the filter query
local: true
},
Ext.apply(this, {
title: 'Inspection',
id: 'inspection', // This is required since title can be changed by filter functions to update status of the grid.
store: 'Inspection',
features: [filters],
selModel: Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }),
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 2
})
],
columns: [{
text: 'ID',
width: 35,
dataIndex: 'id'
},{
text: 'Record Name',
dataIndex: 'record_name',
width: 70,//flex: 1,
hidden: true,
editor: {
queryMode: 'local',
displayField: 'record_name',
valueField: 'record_name',
editable: false
},
filter: {
type: 'string'
}
},{
text: 'Date Created',
dataIndex: 'date_created',
width: 150,
filter: {
type: 'string'
}
}]
});
this.callParent(arguments);
}
});
.
虽然我的代码按预期工作,但它导致我的浏览器挂起适度的时间,然后用通知脚本忙/无响应(Script: http://localhost/lib/ext-4.1.2/ext-all.js:18
)
我不确定这个问题是否与我的EXTJS,我的代码或浏览器的版本不同。如果有人可以帮助它会非常感谢。
解决方案
隐藏和显示可能是昂贵的操作,因为它们涉及操纵DOM和随后的浏览器的回流。对于几行,它不会创建相当大的延迟,但随着许多行增加您可以体验放缓。
我可能会考虑打开一个单独的EXT窗口,表单包含用于编辑的所有字段,不显示和隐藏网格的所有行的列。
不隶属于 StackOverflow