【发布时间】:2015-10-26 16:48:09
【问题描述】:
我遇到了主题中描述的问题。
我有 ExtJs 应用程序。我的任务显示带有填充网格的弹出窗口。
默认window.closable = false;
在控制器的某个地方我定义了窗口,它看起来像这样:
Ext.define('Return.controller.ViewportController', {
extend: 'Ext.app.Controller',
views:[
'ModalWindow',
'ProductsList'
],
stores:[
...,
'ProductsStore'
],
models:[
...,
'ProductsModel'
],
resultWindow: Ext.create('Ext.window.Window', {
itemId: 'popupWindow',
id: 'popupWindow',
title: 'Result List',
layout:'fit',
width: 900,
height: 600,
modal: true,
closable: false,
closeAction: 'hide',
items:[]
})
onPopupShow: function() {
// first add grid with store to popup window;
// then need to load data into ProductsStore;
// depending on values in store_stock column need to define
// if I should show close button for Window or not.
// By default button is invisible
var prodStore = Ext.getStore('ProductsStore');
this.resultWindow.add({xtype: 'ProductsList', border: true});
prodStore.load({
params: {
stock_locations_id: 1,
query: value
},
callback: function (result) {
var app = this;
if (result.length > 0) {
//make window closable
app.resultWindow.closable = (!prodStore.sum('stock'));
//show and update Layout
app.resultWindow.show().updateLayout();
Ext.getCmp('ProductsList').getView().refresh();
return;
}
//do smth else
}, scope: this
});
}
);
用户应执行以下操作: 在 popupShow 上找到网格中的任何行,单击它。之后,弹出窗口将被隐藏,所选行将与所有数据一起添加到父网格中。
prodStore.sum('stock') 工作正常 - 表示列中所有值的总和大于零。
当'stock' 列中的所有值都为零时,用户应该能够关闭窗口。
当我调试那段代码时,window 将 closable 属性设置为 true 并且可以显示。但在正常运行中 - 不。
在尝试签入控制台Ext.getCmp('popupWidow').closable 的同时,它会根据我的需要返回true。
我想应该更新布局。我在显示窗口后立即执行此操作。但很遗憾。
这里还有什么适用的方式?
提前致谢。
【问题讨论】:
标签: javascript extjs extjs4