RadGrid for ASP.NET AJAX

RadControls for ASP.NET AJAX

This example shows how to implement 'Google-like style' filtering in RadGrid.

It allows displaying the available options while the user types in a RadComboBox in RadGrid filtering item. Filtering is confirmed when item is selected or Enter is pressed.

Here is the list of actions needed to achieve this:

  • Extend the default GridBoundColumn to remove the default textbox and embed RadComboBox inside the filtering cell.

  • Configure the options for RadComboBox control as per your requirements (the essential parts are to set ShowToggleImage = false, ID for the combobox, EnableLoadOnDemand=true, MarkFirstMatch = true and attach the ItemsRequested/SelectedIndexChanged events). These operation should take place in the overriden SetupFilterControls(TableCell cell) method.

  • Override the SetCurrentFilterValueToControl(TableCell cell) / GetCurrentFilterValueFromControl(TableCell cell) methods to set/get the user input.

  • Filter the combobox items in the ItemsRequested handler depending on the UniqueName of the currently filtered column.

  • Raise command event for the GridFilteringItem calling its FireCommandEvent(commandName, new Pair(filterFunctionName, columnUniqueName)) method.

This example is expanded by enabling the AJAXmechanism of the grid along with its built-in paging and sorting features. The filtering action will be triggered when you choose item from a look-up textbox or type inside filtering input and press Enter from the keyboard.

In addition, there is Clear filter button on the page which restores the initial grid content.

Note: In this case search is performed for matches in the default grid source on each filter command. That is why each column's CurrentFilterFunction is set to GridKnownFunction.NoFilter and CurrentFilterValue to String.Empty on filter operation.

Google-like filtering