We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Keep GridDataControl state when Filter Clear button is pressed

We have activated the FilterBar for our GridDataControl. The GDC contains Child-Grids.

When we enter a filter and than press the cler filter button in the bottom line, two things happen:

- The complete grid collapses
- SortColumnsChanging events which have been added to the table of the child grid are no longer there?

How can I prevent all this from happening, all I want is reset the filter.

I couldn't even find an event which fires, when the reset happens. I tried all Loaded, Unloaded, Changed and similar events I could find on the Grid, the Model and the Child's model.

Please help on this topic.

1 Reply

JG Jai Ganesh S Syncfusion Team June 20, 2016 12:57 PM UTC

Hi Volker, 
 
Query 1: 
 
You can achieve your requirement for maintaining the grid state when we apply and clear the filter by using FilterChanging and FilterChanged event like below, 
 
dataGrid.Model.FilterChanging += Model_FilterChanging; 
dataGrid.Model.FilterChanged += Model_FilterChanged; 
 
 
    void Model_FilterChanged(object sender, GridFilterEventArgs e) 
        { 
            foreach (var gdr in ExpandedRecords) 
            { 
                var recordIndex = this.dataGrid.Model.View.Records.IndexOfRecord((gdr as GridDataRecord).Data); 
 
                if (recordIndex > 0) 
                    (this.dataGrid.Model.View.Records[recordIndex] as GridDataRecord).IsDetailsViewExpanded = true; 
            } 
        } 
 
        void Model_FilterChanging(object sender, Syncfusion.Windows.Controls.Grid.GridFilterEventArgs e) 
        { 
            ExpandedRecords = new List<GridDataRecord>(); 
            var s = dataGrid.Model.View.Records; 
            foreach (var gdr in dataGrid.Model.View.Records) 
            { 
                var record = gdr as GridDataRecord;                 
                if (record.IsDetailsViewExpanded) 
                    ExpandedRecords.Add(record); 
            } 
        } 
 
 
Query 2: (SortColumnsChanging events which have been added to the table of the child grid are no longer there
 
Could you please let us know, in which event inside you have wired the SortColumnsChanging event of DetailsView ? 
 
Regards, 
Jai Ganesh S 
 


Loader.
Up arrow icon