gpt4 book ai didi

javascript - Extjs 缓存 JSON 请求

转载 作者:行者123 更新时间:2023-11-30 18:54:27 26 4
gpt4 key购买 nike

您好,我正在使用 Extjs,我已经构建了一个包含可编辑单元格的网格。其中一个单元格必须是一个组合框,它从生成 json 数据的脚本中获取其选项。网格和组合框单元格编辑器的代码有效,但我希望在第一次之后缓存对脚本的 json 请求,这可能吗?

我写了一些代码,这是我在网格构造函数中声明组合框列的部分:

{
dataIndex:"authors_name",
id:"authors_name",
header:"Authors",
editable:true,
sortable:true,
editor:{
xtype:"combo",
allowBlank:false,
editable:false,
forceSelection: true,
displayField: 'authors_name',
valueField: 'authors_id',
store:new Ext.data.JsonStore({
proxy:new Ext.data.HttpProxy({
//This is the json request to cache
url: 'index.php?load=authors'
}),
root: 'items',
fields: ['authors_name','authors_id']
})
}
}

最佳答案

我已经通过在 ext 论坛上发帖找到了答案,如果有人感兴趣,这是解决方案:

{
dataIndex:"authors_name",
id:"authors_name",
header:"Authors",
editable:true,
sortable:true,
editor:{
xtype:"combo",
allowBlank:false,
editable:false,
forceSelection: true,
displayField: 'authors_name',
valueField: 'authors_id',
//Add mode and triggerAction properties to make it work locally
mode:"local",
triggerAction:"all",
store:new Ext.data.JsonStore({
proxy:new Ext.data.HttpProxy({
url: 'index.php?load=categories&request=data&type=getAuthors'
}),
//Use the autoload property to do the request only one time
autoLoad:true,
root: 'items',
fields: ['authors_name','authors_id']
})
}
}

关于javascript - Extjs 缓存 JSON 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2674006/

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