PDA

View Full Version : [SOLVED] How to filter a grid or a data store on a foreign key



lpastor
29 Aug 2009, 1:05 PM
Hello,

I have two grids in a window, which each have their data in store1 and store2.

When I select a row in a left one, I would like to filter the right one with the key selected.

I know to get the foreign key of the left grid :


listeners: {
rowclick: function(g, index, ev) {
var id = g.store.getAt(index).data.id_projet;
}
}But now, how filter the second (store2) grid with the id selected ?

lpastor
29 Aug 2009, 2:28 PM
I am near the solution, I do a server side filtering, that work, data come filtered :


listeners: {
rowclick: function(g, index, ev) {
store_action.reload( { params: {requete_appli: " where id_projet_action='"+id+"'"} } ) ;
}
}But I have juste a problem grid isn't empty when store.reload.

I explain:

1. If I select a row in grid 1 with no same id_projet_action in store_action, nothing appear in grid 2 (That's OK)
2. If I select a row in grid 1 with same id_projet_action in store_action, data linked appear in grid 2 (That's OK)
3. After that, if I select a row in grid 1 with no same id_projet_action in store_action, old data appear in grid 2 (That's not OK)

Also how delete all data in a grid to empty it before the reload ?

lpastor
29 Aug 2009, 2:43 PM
Solved !

The solution :


store_action.removeAll();
store_action.reload( { params: {requete_appli: " where id_projet_action='"+id+"'"} } ) ;