-
26 Mar 2012 12:57 PM #1
Unanswered: Ext.List LoadMask only shows on first load
Unanswered: Ext.List LoadMask only shows on first load
My app has a search form that takes user input and binds search results to an Ext.List object (I am also using the ListPaging plugin). In the submit delegate for the search form, I run the following code. The first time a search is run, sencha's default greyed-out 'loading' mask is shown until the list is displayed. Every subsequent search just shows nothing until the list is displayed. Can anyone tell what is wrong here:
Code:onSearchSubmit: function() { var searchInput = Ext.getCmp('searchField'); var searchValue = searchInput.getValue(); var store = Ext.getStore('SearchResults'); store.removeAll(); store.getProxy().setExtraParam('query', searchValue); store.loadPage(1); }
-
27 Mar 2012 4:47 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
This code is working for me.
This is the JSON:Code:var store = new Ext.data.Store({ fields : ['test'], proxy : { type : 'ajax', url : 'data/php.php', extraParams : { sleep : 2 //use sleep() in PHP to defer }, reader : { type : 'json', rootProperty : 'data' } } }); new Ext.Container({ fullscreen : true, layout : 'fit', items : [ { xtype : 'toolbar', docked : 'top', items : [ { text : 'Load Page One', handler : function() { store.loadPage(0); } }, { text : 'Load Page Two', handler : function() { store.loadPage(1); } } ] }, { xtype : 'list', store : store, itemTpl : '{test}' } ] });
Code:{ "success": true, "total": 10, "data": [ { "test": "One" }, { "test": "Two" } ] }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
28 Mar 2012 8:59 AM #3
The problem appears to be with the ListPaging plugin. Adding the plugin causes the load mask to stop working after the first load. Here is a complete example of the problem using Twitters's JSON API:
/app/controller.Search.js:
/app/store/SearchResults.js:Code:Ext.define('LoadMaskTest.controller.Search', { extend: 'Ext.app.Controller', config: { control: { '#searchFormPanel': { submit: 'onSearchSubmit' }, } }, onSearchSubmit: function() { var searchInput = Ext.getCmp('searchField'); var searchValue = searchInput.getValue(); var store = Ext.getStore('SearchResults'); store.removeAll(); store.getProxy().setExtraParam('q', searchValue); store.loadPage(1); }, });
/app/view/Viewport.js:Code:Ext.define('LoadMaskTest.store.SearchResults', { extend: 'Ext.data.Store', config: { clearOnPageLoad: false, fields: [ { name: 'id' }, { name: 'text' }, ], proxy: { type: 'jsonp', url: 'http://search.twitter.com/search.json', reader: { rootProperty: 'results' } }, }, });
/app.js:Code:Ext.define('LoadMaskTest.view.Viewport', { extend: 'Ext.Container', config: { layout: 'vbox', items: [ { xtype: 'formpanel', id: 'searchFormPanel', tbar: { text: 'Search' }, items: [ { docked: 'top', xtype: 'toolbar', items: [ { xtype: 'searchfield', id: 'searchField', name: 'searchField', placeHolder: 'Search', }, ] }, ] }, { xtype: 'list', scrollable : 'vertical', styleHtmlContent: true, store : 'SearchResults', itemTpl : '<h3>{text}</h3>', flex: 1, plugins: [ { xclass: 'Ext.plugin.ListPaging', } ], } ] } });
Code:Ext.application({ requires: ['Ext.data.proxy.JsonP'], name: 'LoadMaskTest', views: ['Viewport'], controllers: ['Search'], stores: ['SearchResults'], launch: function () { var panel = Ext.create('LoadMaskTest.view.Viewport'); Ext.Viewport.add(panel); } });
-
11 Apr 2012 1:34 AM #4
-
11 Apr 2012 6:06 AM #5


Reply With Quote