1
我可以发送参数给RestApi网络服务。但我无法动态发送参数。 我需要一个文本框和按钮。SENCHA TOUCH动态休息Api
这里是我的app.js
Ext.application({
name: 'Hello',
models: [ 'GreetingModel' ],
stores: [ 'GreetingStore' ],
views: [ 'GreetingView' ],
launch: function() {
var view = Ext.create('Hello.view.GreetingView', {});
Ext.create('Hello.store.GreetingStore', {
autoLoad: true,
listeners: {
load: function (self, records) {
view.setData(records[0].getData());
}
}
});
}
});
Ext.Loader.setConfig({ disableCaching: false });
我的商店
Ext.define('Hello.store.GreetingStore', {
extend: 'Ext.data.Store',
config: {
model: 'Hello.model.GreetingModel',
proxy: {
type: 'rest',
contentType: "application/json",
dataType: 'jsonp',
url: 'http://localhost:14551/senchaRegister.svc/request'
},
listeners: {
beforeload: function() {
var name = 'Sedat';
this.getProxy().setExtraParam('name', name);
}
}
}
});
我的模型
Ext.define('Hello.model.GreetingModel', {
extend: 'Ext.data.Model',
config: {
fields: ['JSONDataResult']
}
});
,并查看
Ext.define('Hello.view.GreetingView', {
extend: 'Ext.Panel',
config: {
fullscreen: true,
tpl: '<p>Sonuç: {JSONDataResult}</p>',
items:[
{
xtype: 'textfield',
label:'Name',
id:'username'
},
{
xtype: 'button',
name:'send'
handler: function(){
/* Stuffs*/
}
}
]
}
});
我需要任何建议。
感谢您的回答。其实只是我需要textfield和param配对。因为我可以手动发送参数。 – 2014-12-03 14:46:31
刚刚更新我的答案见上面,其中your_text_field_id是您的文本字段的ID。希望它有效。 – RE350 2014-12-03 16:12:43
该代码听起来不错。只是我还有一个问:我的按钮处理程序是什么:) – 2014-12-04 07:44:24