我们可以在 ext 中将静态 json 存储与 radiogroup 绑定吗?
问问题
5655 次
2 回答
8
Radiogroups 和 Stores 在 ExtJS 中没有直接关系。从存储中填充表单值很容易,但是使用存储来实际创建字段需要一些工作。具体来说,你必须做这样的事情(假设 Ext 3.3.1),并且你的 JsonStore 已经设置好了......
var store = <your predefined store, with records>;
var itemsInGroup = [];
store.each( function(record) {
itemsInGroup.push( {
boxLabel: record.someLabel,
name: record.someName,
inputValue: record.someValue
});
});
var myGroup = {
xtype: 'radiogroup',
fieldLabel: 'My Dynamic Radiogroup',
items: itemsInGroup
};
于 2011-04-06T13:04:14.213 回答
0
您可以使用 dataView 进行此操作。根据商店价值,您可以添加单选按钮。假设您的商店有 5 件商品,那么将显示 5 个单选按钮。
var tpl = new Ext.XTemplate('<tpl for=".">', '<div class="thumb-wrap" style="width:210px; float: left;">', '<label >', '<tpl>', '<input type=radioField value={fieldId} >', '</tpl>', '{dataViewFieldName}', '</label>', '</div>', '</tpl>', {
});
var me = this;
this.items = new Ext.DataView({
store: this.store,
tpl: tpl,
overClass: 'x-view-over',
itemSelector: 'div.thumb-wrap',
autoScroll: true
});
this.callParent();
},
于 2014-06-05T08:49:31.957 回答