-
7 Jul 2010 3:51 AM #1
List store help
List store help
hello
i tried in every possible way this combination but it still wont work...
the data is loaded, i can see it into the console but not on the list...
any help appreciated...Code://returned json {"items":[{"threadid":1000187,"group_name":"<img src='imgs/cgroup.gif' width='16' height='16' border='0'> ALFA NET"}, {"threadid":1000149,"group_name":"<img src='imgs/cgroup.gif' width='16' height='16' border='0'> ARMUS D.O.O."}]} ................................................................ Ext.regModel('group_list', { idProperty: "threadid", fields: ["group_name"] }); ......................................... tpl: '<tpl for="."><div class="groups"><strong>{group_name}</strong></div></tpl>', store: new Ext.data.Store({ autoLoad: true, storeId: "vehicle_groups_store", model: "group_list", proxy: new Ext.data.HttpProxy({ url: "get_groups.php", reader: { root: "items" } }) }),
thanx in advance..
-
7 Jul 2010 9:20 AM #2
-
7 Jul 2010 9:51 AM #3
yes!!! thank you very much! so tired today
regards
-
7 Jul 2010 10:25 AM #4
I might be having a similar (or nearby) problem. I'm really struggling with the lack of consistent documentation.
Data returned (by solr):
As you can see, the root is thedata.response.docs, total results is thedata.response.numFound and identifying field is doc-id.Code:{ "responseHeader":{ "status":0, "QTime":0, "params":{ "raw":"true", "fl":"doc-id,common-id,Title,Contributors", "indent":"on", "start":"0", "q":"Title:Java", "wt":"json", "rows":"4"}}, "response":{"numFound":59,"start":0,"docs":[ { "doc-id":"58900", "common-id":"/ebooks/oca1/26/javahead00herguoft", "Title":"Java Head", "Contributors":"Hergesheimer, Joseph"}, { "Contributors":"Rischpater, Ray", "Title":"Beginning Java ME platform", "common-id":"/ebooks/ebooks0/springer/2010-02-11/2/9781430210627", "doc-id":"260661"}, { "Contributors":"Zukowski, John", "Title":"Java 6 platform revealed", "common-id":"/ebooks/ebooks0/springer/2009-12-01/4/9781430201878", "doc-id":"265847"}, { "Contributors":"Wood, Jo", "Title":"Java programming for spatial sciences", "common-id":"/ebooks/ebooks0/tf/2010-04-28/1/0203166175", "doc-id":"252882"} }}
My code:
And I get the error this.model is undefined.Code:Ext.regModel('Document', { fields: ['doc-id', 'common-id', 'Title', 'Contributors'] }); var store = new Ext.data.Store({ autoLoad: true, model: 'Document', proxy: new Ext.data.HttpProxy({ method: 'get', url: 'http://books2.scholarsportal.info/SolrRequest', reader: new Ext.data.JsonReader({ idProperty: 'doc-id', root: 'response.docs' }), baseParams: { wt: 'json', raw: 'true', fl: 'doc-id,common-id,Title,Contributors', start: '0', rows: '10', q: 'Title:Java' } }) });
I'm autoLoading for now, but I assume once this is working I'll be able to to remove the q from baseParams and do store.load({ params: { q: 'Title:Java' } }); ?
Thanks!
Edit: Forgot two things.
Comment: the Ext.List loads and works great with local data, ie using data: [ ... ] in the store.
Question: after store.load(...) will the Ext.List be populated with the store's new data, or do I need to refresh it somehow?
-
7 Jul 2010 11:08 AM #5Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
It should be populated with the stores new data automatically.
-
7 Jul 2010 11:13 AM #6
-
7 Jul 2010 12:29 PM #7
Here is my json store list hacked from the kiva example.
and the template in the HTMLCode:SearchList = Ext.extend(Ext.List, { title: 'Search', itemSelector: 'div.document', singleSelect: true, emptyText: 'No results matching that query.', isLoaded: false, initComponent : function() { Ext.regModel('Search', { fields: ['title'] }); this.store = new Ext.data.Store({model: 'Search'}); this.tpl = new Ext.XTemplate.from('search', {compiled: true}); this.on('selectionchange', function(e, row, rowdata){ this.dataPopup = new LoanInfo({ data: rowdata[0], listeners: { hide: function(){ this.clearSelections(true); }, scope: this } }); this.dataPopup.show(); }); SearchList.superclass.initComponent.call(this); }, filterResults : function(filterBar, values) { var data = Ext.applyIf(values || {}, { gender: null, region: null, sector: null, sort_by: null, q: null }); if (data.q) { // reset filters } setTimeout(function(){ if (!this.isLoaded) { //Ext.getBody().mask(false, '<div class="loading">Loading…</div>'); } }, 1); this.isLoaded = false; Ext.Ajax.request({ url: 'http://localhost:8080/symphony/touch/src/data.json', scope:this, failure: function() { alert("failure"); }, success: function(response, opts) { //Ext.getBody().unmask(); this.isLoaded = true; var docs = Ext.decode(response.responseText); this.update(''); var row, i, ln; if (docs) { for (i = 0, ln = docs.documents.length; i < ln; i++) { row = docs.documents[i]; } this.store.loadData(docs.documents); this.scroller.scrollTo({x: 0, y: 0}, true); } } }); } });
hthCode:<textarea class="x-hidden-display" id="search"> <tpl for="."> <div class="document"> <h1>{title}</h1> <div style="font-size: 10px">{author}</div> </div> </tpl> </textarea>
-
7 Jul 2010 1:55 PM #8
try
regardsCode:reader: { type: 'json', idProperty: 'doc-id', root: 'response.docs' },
-
7 Jul 2010 2:11 PM #9
The reader is already an Ext.data.JsonReader. Tried it though, getting the same error ("this.model is undefined").
Similar Threads
-
Two Ext.list.ListView using the same store
By eztam in forum Ext 3.x: Help & DiscussionReplies: 4Last Post: 26 Oct 2011, 12:54 AM -
Problem with List and JSON Store
By tubamanu in forum Sencha Touch 1.x: DiscussionReplies: 10Last Post: 6 Jul 2010, 1:37 PM -
ComboBox store and refresh list
By sunco in forum Ext 3.x: Help & DiscussionReplies: 4Last Post: 25 Feb 2010, 1:53 PM -
list after store loading
By xiankai in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 7 Dec 2007, 6:46 AM


Reply With Quote

