Why the datagrid master will not filter or sort

I have a master datagrid with a subdatagrid using firedac fdtables and datagriddatabase- adapters. I click on the sort, filter, and edit checkboxes on the master datagrid. ran it to view but when I click on filter, I only get a list of conditions in the list not a list of values in that column. I thought this was automatic setup or do I need to add conditional programming lines on a button or events?

Thanks still learning datagrids
Garnett Pettway

Hi,

Can you provide some more insight? The list should be a distinct list of values to filter on based on the field when connected to a supported dataset type. Ofcourse you can configure to your needs, but maybe can you share a screenshot of what you see and then maybe what you expect?

Which type of dataset are you using? Not all dataset types are supported, in case of a not supported dataset you need to fill the list manually.

I am using FireDac FTDTable Interbase20 as the database manager.

Thanks
Garnett

If the dataset does not filter or show filter values that means that the type of dataset you are using is not supported automatically. Currently we support TClientDataSet, TFDDataSet and our own TTMSFNCDataSet Basically, the type of dataset does not support cloning, therefore it does not automatically fill the list with unique values. To handle sorting/filtering you will need to implement this manually. However, since you are using TFDTable, it's unclear exactly why it does not work since TFDTable inherits from TFDDataSet. There could be some specifics in binding it to Interbase meaning it doesn't allow the default way of filtering/sorting currently implemented in the data grid adapter.

Filtering

procedure TForm7.TMSFNCDataGridDatabaseAdapter1GetFilterValues(Sender: TObject;
AColumn: Integer; AValues: TStrings);
begin
// fill the AValues string list
end;

Afterwards, the grid will try to apply a filter based on those values with a default filter operation based on

  DataLink.DataSet.Filter := '[Filter]';
  DataLink.DataSet.Filtered := True;

If typing "V88" also does not return a filtered result, this means that the dataset is not capable of applying filters in the default way via the above code. If this is the case, you'll need to lookup the way the dataset needs to be filtered, and apply the filtering code yourself in the following event:

procedure TForm1.TMSFNCDataGridDatabaseAdapter1FilterData(Sender: TObject);
begin
  //apply filter on dataset
end;

There is currently no easy way to handle this other than manually looping through the filter, you can see in the source code of TMSFNCDataGridDatabaseAdapter.ApplyFilter how the filter from the grid is transfered to the filter on the dataset.

Sorting

The implementation uses a index based system and this is unique for each dataset type. If the dataset you are using is not supported then you need to implementing sorting manually. This can be done in the following event:
procedure TForm1.TMSFNCDataGridDatabaseAdapter1SortData(Sender: TObject);
begin
  //apply sorting on dataset
end;

TMSFNCDataGridDatabaseAdapter.SortData shows how to implementing sorting indexed based, retrieving the grid sorting and apply it on the dataset.

Feel free to send me a test project if you have difficulties implementing this, I'll be happy to help out implementing filtering / sorting.

Issue with filtering datagrid using firedac fdtable tables. Is there a flag(s) or setting within the datagrid or datagriddatabaseadapter that would not allow filtering or could it be that master/detail datagrids has an issue with the master datagrid filtering?

Hi,

Master-detail should not affect sort / filter

We have tested with Interbase Database Manager based on the Employee Table, and are succesfully able to connect, filter & sort. No special properties were set to enable this.

Sorry Pieter, after your post, I deleted the master datagrid and added another master datagrid. Now, it is working as expected.

There must be something that happened during the process; however that is why I asked if there was a switch that would set the datagrid back to original state?

Thanks still learning

Garnett

Hi,

Very strange, there has to be some kind of loading sequence, I always recommend to activate the adapter in the formshow, or from a button click, as the very last step after all properties of the data grid & the adapter are configured.

After further investigating,Its seems to be that if dataadapter loadmode = almallrecords filter does not work as expected. It does not give the values in the dropdown filter only ALL, Empty, not Empty. .

However, if I change it to loadmode = almbuffered filter show expected values in the dropdown.

I do not see any data issues. master fdtbl8 keys ID, DEFSITE

detail fdtbl8b keys ID, DEFSITE, SORTID

What could cause this?

Thanks

Garnett

Hi,

I mentioned it a bit earlier in this thread. FDTable should support sorting & filtering, but there could be settings at dataset level that prevent from taking a clone, which is essential for retrieving values in the filter. In LoadMode := almAllRecords, the data is loaded in memory, which can be used by the grid to build up the filter. So, We have tested here with an FDTable, but it could essentially also be the connection lying behind it that does not automatically enable this feature.

Pieter,

I have put together a sample database MMCINV1

MMCINV1.zip (226.1 KB)

Datagrid.zip (8.6 MB)

.IB and a sample project PROJDATAGRID showing the issue with not filtering on the master datagrid when I set the LoadMode= almAllrecords. If I set it to almbuffered the filtering stops or if I remove the DetailControl value BOMITEMSDATAGRID filtering works on the master datagrid.

I uploaded two zip files for this test

Please review and test

Thanks

Garnett

Hi,

Thank you for your sample. We are able to reproduce this issue and are looking for a solution. Stay Tuned

Hi,

We applied a fix for this ,next version will address this issue.

Thanks Pieter,