View Full Version : Change datastore of grid by click

8 Oct 2007, 7:07 AM
Hi, i don't know how to change the datastore of a grid by a click. I have a list (a combobox) with many possibilities of content for my data grid, and when the user choose a content, it must change the content in the grid.. i have found examples but there are not the same thing, or i don't have understood (which is possible also...)

here my code :

var store = new Ext.data.JsonStore({
url: 'listingClientsJson.php',
root: 'libel',
fields: ['id','libel']

var combo = new Ext.form.ComboBox({
store: storeClients,
typeAhead: true,
triggerAction: 'all',
emptyText:'Choisir un compte client...',

combo.addListener('select', function(){ alert(this.value) ;
// should be something as "changeContent(this.value) ;

any help should be very appreciated.. thanks

8 Oct 2007, 7:56 AM
you have to put

combo.on('select', function() {
combo_filtre: combo.getValue()

where ds_grid is your grid's data store

10 Oct 2007, 6:55 AM
thanks, but i don't see what your combo_filtre should do? in fact, i want to do the same thing that in this example (the first) : http://www.openntf.org/extnd/demo.nsf/demo-singlecategory-views.html!OpenPage

11 Oct 2007, 12:05 AM

11 Oct 2007, 12:16 AM
What Footeuz is demonstrating to you is that when an item is selected in your combo, you reload the data for store using the selected item's value to filter it - the assumption is that listingClientsJson.php will filter your back-end data depending on this value. It's like calling the store's url with:

listingClientsJson.php?combo_filtre=/* value */

With this method, it's up to you to write the PHP to filter the data.

You could also use filter (http://extjs.com/deploy/ext/docs/output/Ext.data.Store.html#filter) or query (http://extjs.com/deploy/ext/docs/output/Ext.data.Store.html#query) to limit what's displayed in the grid.

12 Oct 2007, 12:58 PM
yes of course!! it's simple in fact.... yes... thank you very much!