商店更新后如何调整 Sencha Touch 选择字段选择器的大小?
我正在开发 Sencha Touch 应用程序。我目前正在尝试获取由商店填充的 SelectField。
我的商店的代码是:
var store_Blocks = new Ext.data.JsonStore({
model: 'Blocks',
proxy: {
type: 'ajax',
url: '/search-blocks',
},
autoLoad: false,
remoteFilter: true,
listeners: {
load: function(store, records, success) {
Ext.getCmp('selectfield_Blocks').setDisabled(false);
}
}
});
我的选择字段的代码是:
{
id: 'selectfield_Blocks',
xtype: 'selectfield',
name: 'block',
label: 'Block number',
disabled: true,
store: store_Blocks,
listeners: {
change: function(selectfield, block) {
...
}
}
}
该选择字段位于浮动面板内。每次我 show() 浮动面板时,我的商店都会自行更新。因此,选择字段也会更新。但是,这仅在我第一次 show() 面板时有效。随后我 show() 浮动面板时,选择字段正确显示更新的数据,但是当我单击选择字段时显示的选择器未正确调整大小。它的大小根据浮动面板首次显示时有多少行数据而定。
TLDR:商店更新后如何调整 Sencha Touch 选择字段选择器的大小?
下面是屏幕截图。第二次单击选择字段时,选择器面板不会调整大小以适应整个商店的内容。
I'm developing a Sencha Touch application. I'm currently trying to get a SelectField to be populated by store.
The code for my store is:
var store_Blocks = new Ext.data.JsonStore({
model: 'Blocks',
proxy: {
type: 'ajax',
url: '/search-blocks',
},
autoLoad: false,
remoteFilter: true,
listeners: {
load: function(store, records, success) {
Ext.getCmp('selectfield_Blocks').setDisabled(false);
}
}
});
The code for my select field is:
{
id: 'selectfield_Blocks',
xtype: 'selectfield',
name: 'block',
label: 'Block number',
disabled: true,
store: store_Blocks,
listeners: {
change: function(selectfield, block) {
...
}
}
}
This select field is inside a floating panel. Every time I show() the floating panel, my store updates itself. As such, the select field also becomes updated. However, this works only the first time when I show() the panel. The subsequent times I show() the floating panel, the selectfield correctly shows the updated data, but the picker that shows up when I click the selectfield is not correctly resized. It is sized according to how many rows of data there was when the floating panel was first shown.
TLDR: How to resize a Sencha Touch selectfield's picker after the store has been updated?
Below is a screenshot. The second time I click the selectfield, the picker panel does not resize to fit the content of the whole store.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来设置宽度和高度部分解决了问题。
我仍然遇到一些其他问题,有时无法从选择字段中选择项目。很奇怪。
It seems like setting the width and height fixed the problem partly.
I'm still having some other problems where I'm unable to sometimes select an item from the selectfield. Quite weird.
感谢您的解决方法,我做了一些不同的事情
,它可能效率较低,但每次数据更改时它都会自行计算宽度和高度。
Thanks to your workaround I did something a bit different
It might be a bit less efficient, but it calculates the width and height by itself every time the data is changed.