-
16 Oct 2008 8:14 AM #1
Gridfilter using datastore
Gridfilter using datastore
Hi All,
I'm trying to get the following working.
In the gridfilter I would like to use a datastore instead of fixed filter options.
Now I’ve tried to use the store variable, this does give me the correct amount of options but does not show any text in the menu, and if clicked on it the filter does not filter correctly.
Does anybody know an solution?
Datastore for the filter:
The filtersCode:var ds_type = new Ext.data.Store({ id: 'TypeDataStore', proxy: new Ext.data.HttpProxy({ url:'db/type_asset_db.php', method: 'POST' }), reader: new Ext.data.JsonReader({ root: 'results', totalProperty: 'total', id: 'cmdb_type_desc' },[ {mapping: 'cmdb_type_desc', name: 'cmdb_type_desc'} ]) });
Code:var filters = new Ext.grid.GridFilters({ filters:[ {type: 'string', dataIndex: 'System_ID'}, {type: 'string', dataIndex: 'System_Name'}, {type: 'numeric', dataIndex: 'System_HD_Size'}, {type: 'date', dataIndex: 'System_EnterDate'}, {type: 'string', dataIndex: 'System_Model'}, {type: 'list', dataIndex: 'cmdb_type_desc', // options: ['Desktop', 'Laptop', 'Mobiele Telefoon', 'PDA', 'Token'], store: ds_type, phpMode: true }, {type: 'numeric', dataIndex: 'System_Responsible'}, {type: 'string', dataIndex: 'Status_Desc'} ]});
-
26 Nov 2008 1:43 AM #2
I am having a similar issue to yourself. Did you ever get it resolved?
I have got a step further and managed to get the text to display. Add this,
{type: 'list', dataIndex: 'fromAccount', store: accountStore, labelField:'name'}
UPDATE
Anotehr bit further I don't know how to correctly fix this but In the ListMenu class the onload function is assigning the itemId equal to that of the current record. This means the labelField value is being checked against the record id rather than the actual data it should be. I made this change to the ListMenu class and it works (this is a breaking change though so shouldn't be relied upon)
UPDATE 2Code:onLoad: function(store, records){ var visible = this.isVisible(); this.hide(false); this.removeAll(); var gid = this.single ? Ext.id() : null; for(var i=0, len=records.length; i<len; i++){ var item = new Ext.menu.CheckItem({ text: records[i].get(this.labelField), group: gid, checked: this.selected.indexOf(records[i].id) > -1, hideOnClick: false}); item.itemId = records[i].data.name; /* I DID A CHANGE */ item.on('checkchange', this.checkChange, this); this.add(item); } this.loaded = true; if(visible) this.show(); this.fireEvent('load', this, records); },
Actually How stupid of me - if you specify the id to be the same as your labelField value you'll be flying
... reader: new Ext.data.XmlReader({record: 'account', id:'name'}, Account), ...Last edited by kouphax; 26 Nov 2008 at 2:17 AM. Reason: update on problem
-
18 Feb 2011 1:16 AM #3
better to use this:
Code:/** @private */ onLoad: function(store, records){ var visible = this.isVisible(); this.hide(false); this.removeAll(); var gid = this.single ? Ext.id() : null; for(var i=0, len=records.length; i<len; i++){ var item = new Ext.menu.CheckItem({ text: records[i].get(this.labelField), group: gid, checked: this.selected.indexOf(records[i].id) > -1, hideOnClick: false}); item.itemId = records[i].get(this.labelField); /* USING labelField INSTEAD OF an user specific store field */ item.on('checkchange', this.checkChange, this); this.add(item); } this.loaded = true; if(visible) this.show(); this.fireEvent('load', this, records); },
-
27 Jan 2013 11:41 AM #4
After all these years of trying
After all these years of trying
Hi All,
First of all thanks for the input of getting the solution.
After some while of trying I decided to skip the issue and use the standard options: [].
Recently I had to make a new version of the application with new features in it.
Started with Architect 2 to build is in extjs 4.1, got the list filter with store working, but got tangled up in some other head-breaking issue. So got back to the drawing-board with extjs 3.4.
After some hick-ups I found the solution to my initial problem in Oct 2008.
Here is my Solution:
Adjust the file (found in menu folder) - ListMenu.js
1. Under the constructor : make the following change, replace
intoCode:this.store.on('load', this.onLoad, this)
2. then the next step, in the onloadCode:} else { this.add({text: this.loadingText, iconCls: 'loading-indicator'}); //this.store.on('load', this.onLoad, this); var storeObject = Ext.StoreMgr.lookup(this.store); storeObject.on('load', this.onLoad, this); this.store = storeObject; } }, destroy : function () {
intoCode:item.itemId = records[i].id;
Thanks again.Code:hideOnClick: false}); //item.itemId = records[i].id; item.itemId = records[i].get('id'); item.on('checkchange', this.checkChange, this);
Hope you will have some fun with it.


Reply With Quote