PDA

View Full Version : [CLOSED] GridPanel Filter with Checked Selections



elisa
Aug 09, 2013, 3:28 PM
I have a GridPanel using a CheckboxSelectionModel with a text filter that displays matches from the store as you type:
6732

This is the js function that is executed to apply the text filter:


function ApplyTextFilter(sender, textField) {
var grid = Ext.getCmp(sender);
var dataIndex = grid.getId().replace("_Grid", "");

var store = grid.getStore();

store.filterBy(function (record) {
var value = textField.getValue() || "";
var val = record.get(dataIndex).toLowerCase();
return val.indexOf(value.toLowerCase()) > -1;
}
);
}


The problem is that when I make checkbox selections, and then apply a new text filter, I lose the previous selections. I want to be able to keep the current selections as I search new text. This is a mockup of what I mean:
6733

Any solutions or alternative suggestions would be so appreciated. :) Thanks!

Baidaly
Aug 09, 2013, 6:09 PM
Hello!

How do you load your data? Is it local or remote? We would appreciate a full sample to test.

elisa
Aug 09, 2013, 6:17 PM
Remote. The store is loaded with json data from a web service. This is the response from Fiddler (without any text filter applied):



[{"RECORD_COMPONENT_NAME":"DELL POWEREDGE 1950"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE 2600"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE 2650"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE 2900"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE 2950"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE 6850"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE 6950"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE R510"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE R710"},{"RECORD_COMPONENT_NAME":"DELL POWEREDGE R720"},{"RECORD_COMPONENT_NAME":"FUJITSU PRIMEPOWER 450"},{"RECORD_COMPONENT_NAME":"FUJITSU PRIMEPOWER 650"},{"RECORD_COMPONENT_NAME":"FUJITSU PRIMEPOWER 850"},{"RECORD_COMPONENT_NAME":"FUJITSU SPARC ENTERPRISE M4000"},{"RECORD_COMPONENT_NAME":"FUJITSU SPARC ENTERPRISE M5000"},{"RECORD_COMPONENT_NAME":"HP BLADESYSTEM BL25P"},{"RECORD_COMPONENT_NAME":"HP BLADESYSTEM C7000"},{"RECORD_COMPONENT_NAME":"HP BLP ENCLOSURE (243564-B21)"},{"RECORD_COMPONENT_NAME":"HP PROLIANT BL460C"},{"RECORD_COMPONENT_NAME":"HP PROLIANT BL460C G6"},{"RECORD_COMPONENT_NAME":"HP PROLIANT BL460C G7"},{"RECORD_COMPONENT_NAME":"HP PROLIANT BL685C G6"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL360 G5"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL360 G7"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL380 G3"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL380 G4"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL380 G5"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL380 G6"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL380 G7"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL380P GEN8"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL580 G2"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL580 G3"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL580 G7"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL585"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL585 G2"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL585 G5"},{"RECORD_COMPONENT_NAME":"HP PROLIANT DL585 G6"},{"RECORD_COMPONENT_NAME":"IBM BLADECENTER CHASSIS (8677-2XX)"},{"RECORD_COMPONENT_NAME":"IBM BLADECENTER HS20"},{"RECORD_COMPONENT_NAME":"IBM P5 P520"},{"RECORD_COMPONENT_NAME":"IBM P6 P550"},{"RECORD_COMPONENT_NAME":"IBM P6 P560"},{"RECORD_COMPONENT_NAME":"IBM P7 P750"},{"RECORD_COMPONENT_NAME":"IBM X3650 M3"},{"RECORD_COMPONENT_NAME":"IBM X3750 M4"},{"RECORD_COMPONENT_NAME":"IBM XSERIES 335"},{"RECORD_COMPONENT_NAME":"IBM XSERIES 336"},{"RECORD_COMPONENT_NAME":"IBM XSERIES 346"},{"RECORD_COMPONENT_NAME":"IBM XSERIES 360"},{"RECORD_COMPONENT_NAME":"NICE VOICE LOGGER"},{"RECORD_COMPONENT_NAME":"SUN ENTERPRISE 420R"},{"RECORD_COMPONENT_NAME":"SUN SPARC ENTERPRISE M4000"},{"RECORD_COMPONENT_NAME":"SUN SPARC ENTERPRISE M5000"},{"RECORD_COMPONENT_NAME":"SUN SPARC ENTERPRISE M8000"},{"RECORD_COMPONENT_NAME":"SUN SPARC ENTERPRISE T5220"},{"RECORD_COMPONENT_NAME":"SUN SPARC ENTERPRISE T5240"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE 280R"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE 6800"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE E2900"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE T2000"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE V1280"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE V210"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE V240"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE V440"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE V480"},{"RECORD_COMPONENT_NAME":"SUN SUN FIRE V490"},{"RECORD_COMPONENT_NAME":"SUPERMICRO SC512L-200"},{"RECORD_COMPONENT_NAME":"SUPERMICRO SC823S-R500RC"},{"RECORD_COMPONENT_NAME":"SUPERMICRO X7DB8"},{"RECORD_COMPONENT_NAME":"TOSHIBA FR2100A MODEL 100"}]

Baidaly
Aug 09, 2013, 7:35 PM
You can do the following:

Save your selections:

s = App.GridPanel1.getSelectionModel().getSelection();

And restore them after your after filtration:

App.GridPanel1.getSelectionModel().select(s);

elisa
Aug 09, 2013, 8:02 PM
That worked great. Thanks!