chrwjr
10 Feb 2012, 4:29 PM
OK, I have been spinning my wheels for about 3 days on this issue. I have an application that allows the end-user to select a business customer from a drop down list (combo list) and it displays detail data associated with that customer in a grid. I have added the grid filtering to the column headings. So for example, the "Status Description" field might consist of 10 known statuses and the end-user can filter the data accordingly. It all works well. However, when it comes to the "State Code", a given customer might only do business in 12 states, not all 50. Different customers do business in different combinations of states. So I would like to dynamically regenerate the filter options on the select event of the combo box (locally).
It seems as though I can instantiate the filters thusly:
// Static seeding of filter options:
col_property_state.filter = {
type: 'list',
options: ['AK','AL','AR','AZ','CA','CO','CT','DC','DE','FL','GA']
// , phpMode: true
};
And that works fine. But this does not:
// Dynamic seeding of filter options:
var states = new Array();
for (var i = 0; i < store.getCount(); i++) {
var mystate = store.getAt(i).get("property_state");
for (var j = 0; j < states.length; j++) {
if (states[j] == mystate) break;
}
if (states[j] != mystate) states.push(mystate);
}
var col_property_state = Ext.ComponentManager.get('col_property_state');
col_property_state.filter = {
type: 'list',
options: states
// , phpMode: true
};
col_property_state.filterable = true;
Two issues here:
1.) According to the 4.0 documentation on Ext.ux.grid.filter.ListFilter, "options" can be a string, object or array. Here it is an array, but not working. I have dumped it to a string and tried to no avail. I have tried to specify options: [states] and options: states etc. My console log shows that the array is properly populated.
2.) Secondly, if I instantiate statically, it works fine, but if I then try to change the options element on a combo select event, it ignores the new options. Seems like it should do a destroy or clearFilter of the existing filter and create a new one or update the existing one then fire "updateColumnHeadings()".
Any assistance would be helpful. Thank you.
It seems as though I can instantiate the filters thusly:
// Static seeding of filter options:
col_property_state.filter = {
type: 'list',
options: ['AK','AL','AR','AZ','CA','CO','CT','DC','DE','FL','GA']
// , phpMode: true
};
And that works fine. But this does not:
// Dynamic seeding of filter options:
var states = new Array();
for (var i = 0; i < store.getCount(); i++) {
var mystate = store.getAt(i).get("property_state");
for (var j = 0; j < states.length; j++) {
if (states[j] == mystate) break;
}
if (states[j] != mystate) states.push(mystate);
}
var col_property_state = Ext.ComponentManager.get('col_property_state');
col_property_state.filter = {
type: 'list',
options: states
// , phpMode: true
};
col_property_state.filterable = true;
Two issues here:
1.) According to the 4.0 documentation on Ext.ux.grid.filter.ListFilter, "options" can be a string, object or array. Here it is an array, but not working. I have dumped it to a string and tried to no avail. I have tried to specify options: [states] and options: states etc. My console log shows that the array is properly populated.
2.) Secondly, if I instantiate statically, it works fine, but if I then try to change the options element on a combo select event, it ignores the new options. Seems like it should do a destroy or clearFilter of the existing filter and create a new one or update the existing one then fire "updateColumnHeadings()".
Any assistance would be helpful. Thank you.