I want to parse an xml using sencha touch , i've tried all the possibilities in stckovrflow , but nothing's display :
XML DATA :
from : http://www.aufaitmaroc.com/feeds/maroc.xml
The store :
Ext.define("MyApp2.store.NewsStore", {
extend: "Ext.data.Store",
requires: ["Ext.data.proxy.JsonP", "Ext.dataview.List", "MyApp2.model.News" ,"Ext.data.reader.Xml"],
config: {
model: "MyApp2.model.News",
autoLoad: true,
proxy: {
type: 'jsonp',
url: 'http://www.aufaitmaroc.com/feeds/maroc.xml',
reader: {
type: 'xml',
record: 'item',
rootProperty: 'channel'
}
}
}
});
My model :
Ext.define("MyApp2.model.News", {
extend: "Ext.data.Model",
config: {
type:'tree',
fields: [
{name: 'title', type: 'auto'}
]
}
});
My view :
{
xtype: "list",
store: "NewsStore",
itemTpl: '<h1>{title}</h1>'
}
I've this errors in the console of chrome :
I've tried to resolve my problem :
I add this in my HTTPD.conf of apache (Im using WampServer)
AddType application/x-font-woff .woff
AddType application/rss+xml .xml
and i created : httpd-proxy.conf and put it in the extra folder
My httpd-proxy.conf
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /EMBackend http://localhost:8383/MyApp2/index.html
ProxyPassReverse /EMBackend http://localhost:8383/MyApp2/index.html
<Location /EMBackend>
Order allow,deny
Allow from all
</Location>
I've add this to httpd.conf:
Include conf/extra/httpd-proxy.conf
& stil can't display any data .Any help will be appreciated :)
Ps:I tried to use JsonP like that :
proxy: {
type: 'jsonp',
url: 'https://ajax.googleapis.com/ajax/services/feed/load? v=1.0&q=http://www.aufaitmaroc.com/feeds/maroc.xml',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
}
I dont get all data u can try on puting the url in your browser.
AFAIK JSONP will not work with xml. You will need to use a service like yql to convert the xml to json.
This fiddle is demo of doing that.
Ext.define('MyApp.model.Station', {
extend: 'Ext.data.Model',
config: {
fields: [
'title'
]
}
});
Ext.define('MyApp.store.Stations', {
extend: 'Ext.data.Store',
requires: 'MyApp.model.Station',
config: {
autoLoad: true,
model: 'MyApp.model.Station',
proxy: {
type: 'jsonp',
//url : 'http://www.aufaitmaroc.com/feeds/maroc.xml',
url: 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%20%3D%20%22http%3A%2F%2Fnews.google.co.in%2Fnews%3Fpz%3D1%26cf%3Dall%26ned%3Din%26hl%3Den%26output%3Drss%22&format=json&diagnostics=true',
reader: {
type: 'json',
rootProperty: 'query.results.item'
}
}
}
});
Ext.define('MyApp.list.List', {
extend: 'Ext.List',
config: {
fullscreen: true,
itemTpl: '{title}',
store: Ext.create('MyApp.store.Stations')
}
});
Ext.create('MyApp.list.List');
Using YQL,
Go to yql console page - http://developer.yahoo.com/yql/console/
Type in the following line in the YQL Statement box.
'select * from rss where url = "http://www.aufaitmaroc.com/feeds/maroc.xml"'
Select the json option in the radio button below
Clear the input box on the side of the radio button. It should be empty.
Uncheck both the 'diagnostic' and 'debug' checkbox.
Then press 'Test' button. This should give you the output below.
Now after all this, go to the bottom of the page. There should be the 'THE REST QUERY' section.
There is a url. Note that in the url there will be something like '&callback=' at the end of the url. Remove this, and use the remaining as the url for the store. The callback portion of the url is automatically handled by sencha.
Related
Happy New Year!
I want to place a label in a KendoUI Grid , When my page loads I am passing in the primary key of some table that refers to the description of the value I show in the label. It is working good when the page loads, BUT when I go to add a new row to the grid, it switches back and shows the primary key value in there.
Here is parts of how I have it currently setup:
In the schema of the grid I have added two fields:
ManagerPK: {
type: "number",
defaultValue : SearchVariable
},
ManagerName: {
type: "string"
}
And my Create/Update of the Kendo Grid are defined like this:
create: {
type: "POST",
url: "AddSomeRow",
dataType: "json",
contentType: "application/json"
},
update: {
type: "POST",
url: "UpdateSomeRow",
dataType: "json",
contentType: "application/json"
},
and in the columns definition of the grid for it I defined it like this:
columns: [
{
field: "ManagerPK",
title: "Manager Desc",
width: "8%",
template: "#=ManagerDesc ? ManagerDesc : ''#"
}
So how should I change my code to NOT SHOW the PK and always she the Description?
Ive been trying to use breeze with third party RESTful API - the API expects parameters of two types - deep linking like - localhost/request/5 for single entities (ie. request with id = 5) and parametrised queries using JSON encoded in URL (transformed by breeze with no problem).
The main problem is to make breeze to create request with URL such as:
localhost/request/{id}
not JSON encoded GET, while using breeze query "withParameters( {workorderid: id})"
And the second part of problem is using syntax like:
var query = breeze.EntityQuery
.from('request')
.withParameters(parameters)
.expand('requestDetails');
To query for two entities - main - request - and secondary - requestDetails (with deffered on access querying for value of the secondary object).
The result should be like on this image:
http://postimg.org/image/prurk75ol/
My model is defined by hand with two entities:
metadataStore.addEntityType({
shortName: "request",
namespace: "servicedesk",
dataProperties: {
workorderid: {
dataType: DT.Identity,
isPartOfKey: true
},
ignorerequest: {
dataType: DT.Boolean
}
},
navigationProperties: {
requestDetails: {
entityTypeName: "requestDetails:#servicedesk",
isScalar: true,
associationName: "request_requestDetails",
foreignKeyNames: ["workorderid"]
}
}
});
metadataStore.addEntityType({
shortName: "requestDetails",
namespace: "servicedesk",
dataProperties: {
workorderid: {
dataType: DT.Identity,
isPartOfKey: true
},
group: {
dataType: DT.String
},
description: {
dataType: DT.String
}
},
navigationProperties: {
request: {
entityTypeName: "request:#servicedesk",
isScalar: true,
associationName: "requestDetails_request",
foreignKeyNames: ["workorderid"]
}
}
Ive found example of this: https://github.com/Breeze/breeze.js.labs/blob/master/breeze.ajaxrestinterceptor.js , it looks like i can change url generation by intercepting ajax calls, can this be done for angular.breeze adapter?
I don't fully understand your question. What query are you having trouble with? Please edit your answer so we can help.
BUT I do see what looks like a metadata problem with your definition of the request type's requestDetails navigation property. Both the property name and the semantics suggest this should return a collection but you've defined it as a scalar.
requestDetails: {
entityTypeName: "requestDetails:#servicedesk",
isScalar: true, // <-- HUH?
associationName: "request_requestDetails",
foreignKeyNames: ["workorderid"]
}
I think you want isScalar: false,
Using Sencha Touch, How do we query youtube v3 search api?
Below is the sample url which works fine when issued from a browser directly (NOTE: Key is required) :
"https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&type=video&channelId=UC3djj8jS0370cu_ghKs_Ong&key=MY_KEY"
However the same url fails when loaded using sencha touch Store ajax proxy.
It seems that OPTIONS call is made against this URL and GET was aborted.
What is needed in Sencha touch store for working with youtube V3 google apis? I did not find jsonp support for youtube V3 api.
I have used this api like this,
proxy: {
type: 'ajax',
url: 'https://www.googleapis.com/youtube/v3/search',
useDefaultXhrHeader: false,
extraParams: {
part: 'snippet',
q: 'ambarsariya',
regionCode: 'IN',
maxResults: 30,
key: 'your_key'
},
reader: {
type: 'json',
rootProperty: 'items'
}
}
One more thing you have to do and thats is you have set a idProperty in the model of this store. Inside config of the model used I have used
idProperty: 'videoId',// its better if this name is not same as any fields name
fields: [{
name: 'snippet'
}, {
name: 'thumbnail',
mapping: 'snippet.thumbnails.default.url'
}, {
name: 'title',
mapping: 'snippet.title'
}]
Hope this solves your problem.
It works well for me.
STORE:-
Ext.define('MyApp.store.videos', {
extend: 'Ext.data.Store',
model: 'MyApp.model.Video',
config: {
autoLoad: true,
proxy: {
type: 'ajax',
//This is required to enable cross-domain request
useDefaultXhrHeader: false,
url: 'https://www.googleapis.com/youtube/v3/search',
extraParams: {
part: 'snippet',
q: "Enrique", //Query string
regionCode: 'IN',
maxResults: 30,
key: 'AIzaSyD6FvoLaIFqyQGoEY4oV7TEWGAJSlDd1-8'
}
}
}
});
This is the model used by the above store.
MyApp.model.Video:-
Ext.define('MyApp.model.Video', {
extend: 'Ext.data.Model',
requires: [],
config: {
idProperty: 'videoId',
fields: [{
name: 'id'
}, {
name: 'videoId',
mapping: 'id.videoId'
}]
}
});
It also works well for jsonp proxy also,
just change type: jsonp inside proxy and remove useDefaultXhrHeader config.
When I send data ( store in codeblock ) to my laravel 4 server I get "method not allowed" and the server returns all methods allowed except POST. When I comment out 'id' in my model, everything works. ( don't want to comment out id)
I tried the writeRecordId:false and writeAllFields:false in my writer property but this doesn't remove the id while sending..
Ext.define('Equipment.store.Equipments', {
extend: 'Ext.data.Store',
model: 'Equipment.model.Equipment',
requires: ['Ext.data.proxy.Rest'],
alias: 'store.Equipments',
proxy: {
type: 'rest',
url: '/json/stock/equipment',
reader: {
type: 'json',
root: 'data',
successProperty: 'success'
},
writer: {
type: 'json'
}
},
groupField: 'location'
});
data send:
{"id":0, "location":"Building123","locationDetails":"office 2","locationIndex":"drawre 5", "description":"item 7"}
I guess I've sorta solved it I think:
Ext.define('Equipment.model.Equipment', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id',
type: 'number',
useNull: true
},
Placing 'useNull: true' along id sets {"id":null, ... in the data which is accepted by the server. Anyone care to comment?
My application grid is loading data using the webservice URL to fill grid with coming data. When Im giving URL like
function gridSectionResources()
{
Ext.define('Person', {
extend: 'Ext.data.Model',
fields: ['EmployeeID', 'FirstName', 'LastName','Designation','Role','BillingRate','SignedOn','SignedOff']
});
var store = Ext.create('Ext.data.Store', {
autoLoad: true,
//autoSync: true,
model: 'Person',
proxy: {
type: 'rest',
url:'http://localhost:2012/HBWebService/ws/employees',
// url:'js/Manager/data.json',
reader: {
type: 'json',
root: 'Project'
},
writer: {
type: 'json'
}
}
});
Working fine but
If I'm giving url:'http://172.166.11.9:2012/HBWebService/ws/employees'. It is not working
You must use JsonP proxy for getting data from another domain.
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.JsonP
Ext.define('Person', {
extend: 'Ext.data.Model',
fields: ['EmployeeID', 'FirstName', 'LastName','Designation','Role','BillingRate','SignedOn','SignedOff']
});
var store = Ext.create('Ext.data.Store', {
autoLoad: true,
//autoSync: true,
model: 'Person',
proxy: {
type: 'jsonp',
url:'http://localhost:2012/HBWebService/ws/employees',
// url:'js/Manager/data.json',
reader: {
type: 'json',
root: 'Project'
},
writer: {
type: 'json'
}
}
});