This is a migrated thread and some comments may be shown as answers.

IGridFilterPopup

9 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason Parrish
Top achievements
Rank 1
Jason Parrish asked on 14 Dec 2011, 09:57 PM
I'm trying to find an example of creating a custom grid filter popup.  Anybody have one yet?

9 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 19 Dec 2011, 12:37 PM
Hi Jason,

Thank you for writing.

Can you please specify in greater detail what are you trying to accomplish so we can provide you with adequate help. Information on what types you want to use the filter for and what UI you want would be very helpful.

I am looking forward to you reply.

Kind regards,
Ivan Petrov
the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Jason Parrish
Top achievements
Rank 1
answered on 19 Dec 2011, 03:25 PM
Similar to how the dates are group, I would like to group dollar amounts, e.g "$5 to $10 million" or ">$10 million".  Another example would be a state column, but instead of only showing states existing in the data, I would like to show all states.  Also below the state list, I would like to display checkboxes for East, West, etc.

On a similar note, is there a way I can replace the controls in the filter cell for a column?  If that was possible, that would go a long way as well. 
0
Ivan Petrov
Telerik team
answered on 22 Dec 2011, 11:26 AM
Hello Jason,

Thank you for writing back 

Currently, the filter popup does not allow for adding custom items, but we have planned to improve this and allow developers to fully customize the list with items and the filter descriptors the popup produces. In this line of thoughts we would very much appreciate any feedback you share with us about other scenarios you would like to be able to accomplish with the filter popup and features you want to see.

On your second question. You can customize the filter cell with elements you choose. Please find attached a sample project where I have created a custom cell with a button and a check box which replaces the default filter cell.

I hope this will be useful for you. Should you need further assistance, I would be glad to provide it.

All the best,
Ivan Petrov
the Telerik team

Q3’11
of RadControls for WinForms is available for download (see what's new). Get it today.
0
Jason Parrish
Top achievements
Rank 1
answered on 22 Dec 2011, 04:45 PM
Thank you for the code sample.  I believe I can use that method instead of the popup.  Two questions though....1) How does my custom class actually apply the filter?  Does it need to raise an event?   2)  I noticed that if I group on that field and then ungroup, I lose the customization.  What event should I capture to ensure it's applied again?

Thank you!
0
Svett
Telerik team
answered on 27 Dec 2011, 02:26 PM
Hi Jason,

Here are the answers to your questions:
1. You should perform filtering by modifying the FilterDescriptors collection. You can read more about how you can perform filtering programmatically in the online documentation.
2. I am not able to reproduce the issue with 2011.3 11.1116 version. Nevertheless, you can improve the custom cell element by overriding the IsComaptible method:
public override bool IsCompatible(GridViewColumn data, object context)
{
    return data is GridViewDataColumn && context is GridFilterRowElement;
}

If the proposed solution does not address the second issue, could you illustrate the exact steps that we should follow to reproduce it? This will allow us to investigate it and provide you with further support. Greetings,
Svett
the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Jason Parrish
Top achievements
Rank 1
answered on 27 Dec 2011, 10:41 PM
I am currently using version 2011.3.11.1219.  

The CreateCell event is not fired after ungrouping by a column, so it appears it loses it's CellType upon grouping.


0
Ivan Petrov
Telerik team
answered on 30 Dec 2011, 04:01 PM
Hi Jason,

Thank you for writing back.

I have attached a modified version of the example I previously sent you. In it I have added logic which applies a filter on the column when you check the check box. When you group and ungroup the filter is preserved as well as the toggle state of the check box. If this is not what you had in mind I would kindly ask you to provide some more details on what the example does not achieve.

Looking forward to your reply.
 
All the best,
Ivan Petrov
the Telerik teamSP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).
0
Jason Parrish
Top achievements
Rank 1
answered on 30 Dec 2011, 06:00 PM
Thank you for the additional code.  This took me awhile to track down, and I believe it might be a bug somewhere.  Change your CreateCell event to only change the celltype of a specific column.  It will work fine until you ungroup. Any ideas???

Try this code....

private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
    if (object.ReferenceEquals(e.CellType, typeof(GridFilterCellElement)) && e.Column.HeaderText.ToUpper == "COLUMN 1") {
        e.CellType = typeof(MyGridFilterCellElement);
    }
}
0
Ivan Petrov
Telerik team
answered on 04 Jan 2012, 04:55 PM
Hello Jason Parrish,

Thank you for your reply.

The reason for this behavior is that the RadGridView uses a cache for the cells and when you ungroup it gets a filter cell from the cache from the previous column and it overrides your custom one. To fix this, I have added another custom cell which only inherits from the filter cell and in the IsCompatible method override it says that it is not compatible with the column you want a custom filter cell. I have also changed the class from which your custom cell inherits so the applying of a filter is done with just one method.

I hope this will help. Should you need further assistance, I would be glad to provide it.

All the best,
Ivan Petrov
the Telerik team

SP1
of Q3’11 of RadControls for WinForms is available for download (see what's new).
Tags
GridView
Asked by
Jason Parrish
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Jason Parrish
Top achievements
Rank 1
Svett
Telerik team
Share this question
or