Hi,
I use a TTMSFMXGrid filled by livebindings on a stored procedure.
I set options.filtering.dropdown:=true
and options.filtering.multicolumn:=true;
I implemented the solution given in previous post (set condition:='' in filterSelect event and refresh data)
when first clicking on a filter, the grid is correctly filtered, but when I click on a second dropdown filter, only one (sometimes two) values are displayed in the drop down list.
Is it an issue with livebindings or am I doing something wrong?
Hi,
I'm not sure to understand. This is how my aplication works/
At opening, datas are displayed without filter:
Country State/Province
USA Alaska
USA Florida
Europe Spain
Europe Germany
...... ......
I click the dropdown button in the Country header to select USA. Then I set condition:=''; and refresh my dataset, adding the condition "country=USA", the grid is refilled with the new dataset like this:
Country State/Province
USA Alaska
USA Florida
When I click the dropdown button in the State header to select Florida, the dropdownlist is empty. It should contain Florida and Alaska?
As I said previously, I set MyGrid.options.filtering.Multicolumn:=true;
You say that the grid, after a filtering does not contain the correct values of the original dataset. But when the dataset is closed and fully reloaded, it should contain the actual data of the dataset
do you mean that the values in the dropdownList aren't filled automatically from the values displayed in the column?
I thought it was working that way.
regards
Hi,
Pieter Scheldeman2013-10-08 10:00:57
Actually, the dataset is not really filtered.
When getting a filter in then onFilterSelect event, i set condition:='' then I do the following:
myTBindSourceDBX.active:=false;
BindingSource.SubSQLDataSet is filled with a new query (including a new condition according to filter select)
then
BindingSource.Active:=true;
So, it's a brand new dataset that is linked to the grid, containing only the desired data. The dropdownlist should contain all distinct values of the dataset for this column.
Am I wrong?
The new dataset that is linked, containing only the desired data is the reason why the filter dropdownlist does not contain all the required values by default. That is also the reason why you need to add the correct values directly from the database. Each Active := False / Active := True combination clears the grid with the data, and fills the grid with new data.
I agree, but what about the filter?
The first time the grid is filled, the filter contains all data displayed for each column.
In my example the filter for the column "state" contains Alaska, Florida,Spain, Germany
Once the grid is filled with new data, current filter should be cleared and automatically filled with the new data, just like it does at first filling of the grid.
Instead of this behaviour, all filters are empty. I can't run through the whole dataset(several hundreds of records) to fill the dropdown list each time the user clicks on a filter select.
Isn't there any method to reproduce the initial behaviour when the grid is cleared and refilled?
I suggest to load the data one time directly from the database and store the values in a stringlist for each column, you might need to declare a collection that holds a column, and then use that stringlist to return in the OnNeedFilterDropDownData event?
Pieter Scheldeman2013-10-09 10:54:36
I think I'll give up with this functionality. I don't see the interest of using it, if I have to code everything by myself.
Thanks for your help
best regards