ASPxGridView: Improve Filter by Adding an '(All)' item

ASP.NET Team Blog
13 March 2008

Here is useful tip that can help you improve user experience. When filtering the ASPxGridView with an ASPxComboBox, you can add a new item to the top labeled "All". This can be useful when filtering because the word All is more descriptive than leaving a blank item. You can see an example of this item used on the grid used for the tutorials site:


So what's the trick? Just add a null ListEditItem to the ASPxComboBox. The new (All) item will be inserted above the default blank line that's on the top of the list. It does the same thing, but describing the functionality by changing the name really helps the user. So now you and the users can select the new "All" item to clear filtering for the column. To add this item, override the AutoFilterCellEditorInitialize method as follows:

protected void ASPxGridView1_AutoFilterCellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
   if (e.Column.FieldName == "Country")
      ASPxComboBox comboBox = e.Editor as ASPxComboBox;
      comboBox.ClientSideEvents.Init = "function(s, e) {s.InsertItem(0, '(ALL)', '');}";

First, identify which columns use an ASPXCombobox then add the lines shown above. Now when the filter cell is initialized, the new "All" item will be added.

Enjoy and thanks.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.