gpt4 book ai didi

javascript - 如何使 EXT JS 模型和代理存储工作? (请帮忙!)

转载 作者:行者123 更新时间:2023-11-30 20:05:24 24 4
gpt4 key购买 nike

我还不明白如何使用 REST api 链接服务器数据和表单字段。

我有一些选择字段的表格。我对服务器上的这个特别字段有值。我认为表单可以从存储模型中获取数据(是/否?)。如果这是真的,我有一个问题:如何将现有表单添加到模型中?所以主要目标 - 通过 REST API 从服务器获取值到现有表单的现有选择字段。

这是我现在拥有的:-代理商店:

Ext.define('Foresto.store.RESTstore',{ 
extend: 'Ext.data.Store',
storeID:'reststore',
proxy: {
type:'rest',
url:'http://localhost:6666/api/form',
reader:{
type: 'json',
root: ''
}
},
autoLoad: true});

-来自表单的一个:

Ext.define('Foresto.view.forms.Cutarea', {
extend: 'Ext.form.Panel',
title: 'ForestoL',
header: {
cls: 'header-cls',

},
scrollable: true,
xtype: 'forestoL',

url: 'save-form.php',

items: [{
xtype: 'selectfield',
label: 'Field1',
name: 'name'
},{
xtype: 'selectfield',
label: 'Field2',
name: 'allotment'
}] ...

请帮助!谢谢,阿图尔。

最佳答案

参见 this fiddle一个基本的远程组合框。

{
xtype: 'combo',
fieldLabel: 'My Combo',
valueField: 'id',
displayField: 'title',
anchor: '100%',
store: new Ext.data.Store({
autoLoad: true,
fields: ['id', 'title'],
proxy: {
type: 'ajax',
url: 'records.json'
}
})
}

关于javascript - 如何使 EXT JS 模型和代理存储工作? (请帮忙!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52985070/

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