gpt4 book ai didi

extjs - 如何从数据库中加载组合框中的值

转载 作者:行者123 更新时间:2023-12-01 11:21:24 25 4
gpt4 key购买 nike

我如何填充组合框值而不是从数据库硬编码到组合框的存储中

{
xtype: 'fieldset',
title: 'Dress Types',
items: [
{
xtype: 'combobox',
displayField: "displayName",
valueField: "displayName",
emptyText: 'Select Type',
store: {
fields: ["id", "displayName"],
data: [
{ "id": "1", "displayName": "Kurtha" },
{ "id": "2", "displayName": "Denim Top" },
{ "id": "3", "displayName": "Western T shirt" },
{ "id": "4", "displayName": "Sleeveless" }
]
},
name: 'dresses',
margin: '15px',
allowBlank: false,
forceSelection: true,
}
]
}

提前致谢

最佳答案

您可以通过多种方式获得它。您需要根据输入数据在您的 js 中创建一个商店,然后将其分配给组合框。

举个例子

var combstore = Ext.create('Ext.data.Store', {
autoLoad: true,
fields: [{
name: 'value',
mapping: "ITEMID",
type: 'string'
}, {
name: 'name',
mapping: "TITLE",
type: 'string'
}],
proxy: new Ext.data.HttpProxy({
type: 'ajax',
actionMethods: {
read: "POST"
},
url: Your URL,
headers: {
'Accept': 'application/json; charset=utf-8'
},
reader: {
type: 'json',
rootProperty: 'data'
},
autoLoad: true
})
});

现在在您的组合框中,您可以将此 combstore 调用到您的 store存储:combstore

在变量 combostore 中,我们通过使用 Ext.data.Store 并在字段中放置值来创建一个数据存储。然后在代理方法中调用 url 并映射字段中的值。阅读文档以更好地理解 Doc

关于extjs - 如何从数据库中加载组合框中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42366131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com