extjs - extjs how to pass parameters to a web rest api request
问题描述
I'm now trying to connect Extjs with a web rest api apart from my project. This is my view:
Ext.define('mycomponents.view.comboselview', {
extend: 'Ext.container.Container',
id: 'comboview',
alias: 'widget.comboview',
xtype: 'comboview',
requires: [
'mycomponents.model.comboselmodel'
],
items: [
{
xtype: 'combobox',
reference: 'levels',
publishes: 'value',
fieldLabel: 'Choices',
displayField: 'description',
anchor: '-15',
store: {
type: 'levels'
},
minChars: 0,
queryMode: 'local',
typeAhead: true,
labelWidth: 100,
labelAlign : 'right',
width: 265,
allowBlank: false
}
],
initComponent: function () {
this.callParent(arguments);
var that = this;
console.log('!!!!!!!!!!!!!!!!!!!!!!>>>', that.up());
}
});
Here is my model:
Ext.define('mycomponents.model.comboselmodel', {
extend: 'Ext.data.Model',
fields: [
{
name: 'id',
mapping: 'pk'
},
{
name: 'description',
type: 'string',
mapping: 'description'
},
{
name: 'levelid',
type: 'integer',
mapping: 'levelid'
},
...
]
});
and my store:
Ext.define('mycomponents.store.comboselstore', {
extend: 'Ext.data.Store',
alias: 'store.levels',
model: 'mycomponents.model.comboselmodel',
storeId: 'levels',
restful: true,
autoLoad: true,
proxy: {
type: 'ajax',
headers: {
'Accept': '*/*',
'Cache-Control': 'no-cache',
'Content-Type': 'application/json',
'Authorization': localStorage.token
},
extraParamas: {
sort: 'description',
filter: {
idlevel: {
'null': -1
}
}
},
reader: new Ext.data.JsonReader({
}),
writer: new Ext.data.JsonWriter({
}),
actionMethods: {
read: 'GET'
},
api: {
read: 'apiurl',
create: 'apiurl',
update: 'apiurl',
destroy: 'apiurl'
},
autoSave: true
},
constructor: function (config) {
this.callParent([config]);
console.log('I am entering here!!!')
}
});
I'm trying to fetch resources from my apiurl
which is a web rest api. I need to send some parameters, this code returns me the desired data, but this approach ignores the extraParamas
at all. I can't tell that I went into the documentation and found how to use Extjs with a rest api becasue I was unable to find how to do that in the official documentation, so, I've been googleing for a solution and what I've made so far is getting code snippets from here and there. My question: how to send paramenters to a rest api? what am I doing wrong?
解决方案
你的代码中有一个错字,extraParam a s,什么时候应该是extraParams
推荐阅读
- javascript - 扩展数组时发现不可调用的@@iterator
- r - R错误:“找不到函数“变异””跟随管道运算符
- devextreme - Angular DevExtreme 网格行为
- python-3.x - 我正在尝试从 python 中的命令行提示构建一个字符串,但是我无法从它的列表中删除值
- python - 如何遍历熊猫数据框中的字符串并删除不需要的单词?
- python - 在 pycharm 中,当我尝试访问 googlesheet 时显示以下错误。请我的代码和错误
- discord.js - Discord.js - Discord 机器人停止响应命令
- java - 从 Java 中的字节数组(例如 parquet 文件的内容,例如 example.parquet)中提取 Parquet 模式?
- java - 带有 GridBagLayout 的 JPanel 大小不正确
- c - 如何通过用指针填充指针数组来操作指针数组?