Note that there are some explanatory texts on larger screens.

plurals
  1. POSencha touch: JSONP parsing
    primarykey
    data
    text
    <p><strong>Model:</strong></p> <pre><code>app.models.Category = Ext.regModel("Category", { fields: [ { name: 'CategoryId', type: 'int' }, { name: 'ImageUrl', type: 'string' }, { name: 'ImageUrlFile', type: 'string' }, { name: 'CategoyName', type: 'string' } ] }); </code></pre> <p><strong>Storage:</strong></p> <pre><code>app.stores.CategoryStore = new Ext.data.Store({ id: 'CategoryStore', model: 'Category', autoLoad: true, proxy: { type: 'scripttag', url: 'http://localhost:1303/admin/categoriesservice/getcategories', mehod: 'GET', //not needed callbackKey: 'callback', //not needed reader: { type: 'json', root: 'categories'//not needed with my JSONP }, afterRequest: function (request, success) { console.log("afterRequest"); if (success) { console.log("success"); } else { console.log("failed"); } console.log(request); } } }); </code></pre> <p><strong>Controller:</strong></p> <pre><code>Ext.regController('Home', { index: function () { if (!this.indexView) { this.indexView = this.render({ xtype: 'HomeIndex' }); this.items = [app.views.HomeIndex]; } app.viewport.setActiveItem(this.indexView);//this what i've missed } }); </code></pre> <p><strong>View</strong></p> <pre><code>app.views.HomeIndex = Ext.extend(Ext.DataView, { html: '&lt;div class="gallery-view" style="display: block;width: 300px;border: 1px solid #fff;height: 300px;"&gt;&lt;/div&gt;', store: app.stores.CategoryStore, //full namespace needed itemSelector: 'div.node', initComponent: function () { this.tpl = new Ext.XTemplate( '&lt;div style="padding:10px 5px 5px 5px;"&gt;', '&lt;tpl for="."&gt;', '&lt;div class="node" style="background:url({ImageUrl});"&gt;', '&lt;/div&gt;', '&lt;/tpl&gt;', '&lt;/div&gt;' ); //appened to successful solution this.dataView = new Ext.DataView({ store: this.store, tpl: this.xtpl, itemSelector: 'div.node' }); this.items = [this.dataView]; app.views.HomeIndex.superclass.initComponent.apply(this, arguments); } }); Ext.reg('HomeIndex', app.views.HomeIndex); </code></pre> <p><strong>JSONP Result:</strong></p> <pre><code>GetCategories([{"CategoryId":101,"CategoyName":"אוכל","ImageUrl":"http://www.teleclal.com/YnetApplicationMall/Content/images/categories/rest.png","ImageUrlFile":null,"InsertDate":"\/Date(1314507534000)\/","IsActive":true,"ApplicationId":0,"Applications":null},{"CategoryId":99,"CategoyName":"הצגות ומופעים","ImageUrl":"http://www.teleclal.com/YnetApplicationMall/Content/images/categories/shows.png","ImageUrlFile":null,"InsertDate":"\/Date(1314442037000)\/","IsActive":true,"ApplicationId":100,"Applications":null},{"CategoryId":111,"CategoyName":"בריאות","ImageUrl":"http://www.teleclal.com/YnetApplicationMall/Content/images/categories/spa.png","ImageUrlFile":null,"InsertDate":"\/Date(1314856845000)\/","IsActive":true,"ApplicationId":0,"Applications":null},{"CategoryId":142,"CategoyName":"נופש ותיירות","ImageUrl":"http://www.teleclal.com/YnetApplicationMall/Content/images/categories/vacation.png","ImageUrlFile":null,"InsertDate":"\/Date(1314713031000)\/","IsActive":true,"ApplicationId":0,"Applications":null},{"CategoryId":143,"CategoyName":"ביגוד","ImageUrl":"http://www.teleclal.com/YnetApplicationMall/Content/images/categories/clothes.png","ImageUrlFile":null,"InsertDate":"\/Date(1314713031000)\/","IsActive":true,"ApplicationId":0,"Applications":null},{"CategoryId":144,"CategoyName":"אתרים ואטרקציות","ImageUrl":"http://www.teleclal.com/YnetApplicationMall/Content/images/categories/attraction.png","ImageUrlFile":null,"InsertDate":"\/Date(1314713031000)\/","IsActive":true,"ApplicationId":0,"Applications":null},{"CategoryId":105,"CategoyName":"חשמל","ImageUrl":"http://www.teleclal.com/YnetApplicationMall/Content/images/categories/elctronic.png","ImageUrlFile":null,"InsertDate":"\/Date(1314713031000)\/","IsActive":true,"ApplicationId":0,"Applications":null}]); </code></pre> <p><strong>The exception:</strong> Uncaught TypeError: Cannot read property 'length' of undefined</p> <p><strong>Question:</strong> Help how can i parse via storage or any other way the JSONP issue???</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload