Json reader in is defined for the store as follows:
Ext.define('App.store.MyList', {
extend : 'Ext.data.Store',
model : 'App.model.MyList',
pageSize : 100,
proxy : {
type : 'ajax',
actionMethods : {
create : 'POST',
read : 'POST',
update : 'POST',
destroy : 'POST'
},
root : 'results',
url : 'aaa.htm',
reader : {
type : 'json',
root : 'results',
totalProperty: 'totalCount',
extraProperty: 'abcd'
},
simpleSortMode : true
}
});
How do I read extra property outside the root? I tried to put one inside the reader, it did not work.
try this
grid.getStore().getProxy().getReader().extraProperty
Related
I implement simple RESTful Service. These are Rest request url and the response json data.
http://localhost:8080/RESTfulTestWeb/rest/services/getJson/aupres
{"id":"aupres","passwd":"aaa","age":45,"name":"joseph"}
The problem is ExtJS Store object client can not handle the above json data. These are ExtJS client codes
Ext.define('extjs.model.Member', {
extend: 'Ext.data.Model',
fields : [{
name : 'id',
type : 'string'
}, {
name : 'passwd',
type : 'string'
}, {
name : 'age',
type : 'int'
}, {
name : 'name',
type : 'string'
}]
});
Ext.onReady(function () {
var members = Ext.create('Ext.data.Store', {
model : 'extjs.model.Member',
//autoLoad : true,
proxy: {
type: 'rest',
url : 'http://localhost:8080/RESTfulTestWeb/rest/services/getJson/aupres',
reader: {
type: 'json',
root: 'id',
},
writer: {
type: 'json'
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
})
}
}
},
listeners: {
load: function(members, operation, success) {
if(success) {
alert('response : ' + members.model.length)
} else {
alert('it failed')
}
}
}
})
var onButtonClick = function() {
members.load()
}
The respose is shown like below
"response : 0"
It seems my ExtJS codes fail to contain the json data.
The rest proxy reader in ExtJs 5 and up looks for a rootProperty: instead of root:.
HI You can overwrite toString() method of your class . then you can get exact.
Like you want data on ["id":"aupres","passwd":"aaa","age":45,"name":"joseph"}]
or some other format
I have a Facebook SDK Batch, and one of the requests is returning the following error:
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
Here's the Batch:
FB.api('/', 'POST', {
batch: [
{
method : 'GET',
name : 'user',
relative_url : '/me'
},
{
method: 'GET',
name : 'post-ids',
relative_url: '/group-id/feed?fields=id',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-data',
relative_url : '?ids={result=post-ids:$.data.*.id}&fields=id,actions,application,from,to,message,message_tags,with_tags,picture,place,properties,source,status_type,link,description,caption,attachments,object_id,type,created_time,updated_time,likes.summary(1),comments.summary(1)',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-user-info',
relative_url : '/{result=post-data:$.data.*.from.id}/',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-likes',
relative_url : '?ids={result=post-ids:$.data.*.id}/likes?limit=5000',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-comments',
relative_url : '?ids={result=post-ids:$.data.*.id}/comments?fields=id,actions,application,from,to,message,message_tags,with_tags,picture,place,properties,source,status_type,link,description,caption,attachments,object_id,type,created_time,updated_time,likes.summary(1)&limit=5000',
omit_response_on_success : false
}
]
}, function (response) {
The fourth request, name post-user-info is the errant request. Basically, for each post, I want to get the information (profile picture in particular) about the user that created the post. What's the best way to do this?
I am trying to link my grid with a store, which is using a proxy to connect to some outside source. This is how I have set it up :
Ext.define('js.dmwf.PackageStore', {
extend: 'Ext.data.JsonStore',
model: 'js.model.Package',
remoteFiler : false,
remoteSort: false,
autoLoad: true,
proxy: {
type: 'json',
url : 'mock/GetPackageListBB.json',
reader: {
type: 'json'
},
} });
However I am getting an error. Which is happening in the parseNamespace function in ext-all-debug.
Uncaught TypeError: Cannot read property 'substring' of undefined
ext-all-debug.js:5043
Ext.ClassManager.parseNamespace ext-all-debug.js:5043
I have a feeling that I am missing an import or two. However i think i have everything :
Ext.require([
'Ext.data.*',
'Ext.data.proxy.*',
'Ext.data.reader.*',
'Ext.grid.*',
'Ext.tree.*',
'Ext.ux.grid.FiltersFeature',
'Ext.toolbar.Paging',
'Ext.ux.form.SearchField',
'Ext.util.*',
'Ext.state.*'
// 'Ext.ux.grid.Search'
]);
I have a fiddle too :
https://fiddle.sencha.com/#fiddle/6jq
Proxy type needs to be 'ajax'.
proxy: {
type: 'ajax',
...
}
Am new at sencha touch and
I want to create a formPanel after the user click on some listener, I found out how to listen to An item, but the problem is to create a page and fill it with data coming from JsonP request
I tried
Ext.data.JsonP.request({
url: 'url',
callbackName: 'callback1',
success: function(result, request) {
Ext.Viewport.add({
title : 'Category',
iconCls : 'home',
id:'category'+id,
xtype : 'formpanel',
deferredRender:true,
tabBarPosition : 'bottom',
data:result.prop
}); }});
in the console there is no error and the form added but not within the formpanel that already exist
you could try sample code below..
onButtonClick: function(button) {
Ext.data.JsonP.request({
url: 'url',
callbackName: 'callback1',
success: function(result, request) {
button.up('some_id').add({
title : 'Category',
iconCls : 'home',
id:'category'+id,
xtype : 'formpanel',
deferredRender:true,
tabBarPosition : 'bottom',
data:result.prop
});
}});
}
Hi I need to save a variable in Javascript and give it to uploadify.
This is my code:
var mediaID;
$(".edit_photo_media").live("click", function() {
mediaID = $(this).data("media-id");
$.ajax({
url: 'edit.php?action=media_select',
type: 'GET',
dataType: 'html',
success: function (select) {
if (select == '3') {
document.location = "login.php";
} else {
$("#dialog_upload_media").dialog("open");
}
}
});
return false;
});
$('#file_upload').uploadify({
'fileTypeDesc' : 'Image Files',
'fileTypeExts' : '*.jpg;',
'fileSizeLimit' : '4096KB',
'debug' : true,
'method' : 'post',
'formData' : {'id' : '' + mediaID},
'swf' : 'include/swf/uploadify.swf',
'uploader' : 'include/scripts/upload_mult.php'
});
So everytime before the uploader is opened .edit_photo_media is clicked.
<img src="images/photo.png" />
This is where the var mediaID is getting its content. Inside .edit_photo_media mediaID is defined correct.
But if I click the upload button mediaID is undefined. Why is the variable loosing its value?
Edit: Ok this seems to be related to a uploadify bug? If I check mediaID on any other function it is working fine... rlly strange
Ok problem solved. Just added 'onUploadStart' and saved the id in there
$('#file_upload').uploadify({
'fileTypeDesc' : 'Image Files',
'fileTypeExts' : '*.jpg;',
'fileSizeLimit' : '4096KB',
'buttonText' : 'Bilder auswählen',
'debug' : true,
'method' : 'post',
'formData' : {'id' : 0},
'swf' : 'include/swf/uploadify.swf',
'uploader' : 'include/scripts/upload_mult.php',
'onUploadStart' : function(file) {
$('#file_upload').uploadify("settings", "formData", {"id": mediaID});
}
});
jQuery only started subsuming HTML5 data properties set in the source code from version 1.6 onwards. If you're using < 1.6, this won't happen, in which case upgrade jQ.