Product Bundles
DevCraft
All Telerik .NET and Kendo UI JavaScript components and AI Tools in one package.
Kendo UI
Bundle of AI Tools plus four JavaScript UI libraries built natively for jQuery, Angular, React and Vue.
Build JavaScript UI
Javascript
Telerik
Build modern .NET business apps
.Net Web
Cross-Platform
Desktop
Reporting and Documents
AI for Developers & IT
Ensure AI program success
AI for UI
AI Engineering
Additional Tools
Enhance the developer and designer experience
Testing & Mocking
Debugging
UI Tools
CMS
Free Tools
Support and Learning
Productivity and Design Tools
/// <summary>
/// Represents a filtercell that will clear all filters.
/// </summary>
public
class
ClearAllFiltersCell : GridFilterCellElement
{
private
RadButtonElement btnClearAll;
/// Initializes a new instance of the <see cref="CheckBoxHeaderCell"/> class.
/// <param name="column"></param>
/// <param name="row"></param>
ClearAllFiltersCell(GridViewDataColumn column, GridRowElement row)
:
base
(column, row)
}
/// Creates the child elements.
protected
override
void
CreateChildElements()
// The clear all button
btnClearAll =
new
RadButtonElement();
btnClearAll.Text =
"Clear All"
;
btnClearAll.Click +=
EventHandler(btnClearAll_Click);
// Create the child elements, otherwise the necessary elements are not in place
.CreateChildElements();
// Clear all children
this
.Children.Clear();
// Add our button
.Children.Add(btnClearAll);
/// Adds the editor.
/// <param name="editor">The editor.</param>
AddEditor(IInputEditor editor)
// Override this and leave it blank. Clicking on the clear all button will
// still trigger adding an editor and we dont' want that.
/// Arranges the override.
/// <param name="finalSize">The final size.</param>
/// <returns></returns>
SizeF ArrangeOverride(SizeF finalSize)
// This will correctly set the cell size so the clear all button is centered in the cell
SizeF size =
.ArrangeOverride(finalSize);
RectangleF rect = GetClientRectangle(finalSize);
.btnClearAll.Arrange(
RectangleF((finalSize.Width -
.btnClearAll.DesiredSize.Width) / 2, (rect.Height - 20) / 2, 20, 20));
return
size;
/// Handles the Click event of the btnClearAll control.
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
btnClearAll_Click(
object
sender, EventArgs e)
// Clear all the filter decriptors
.GridControl.FilterDescriptors.Clear();
radGridView1_CreateCell(
sender, Telerik.WinControls.UI.GridViewCreateCellEventArgs e)
if
(e.Row
is
GridFilterRowElement)
// Replace "Id" with the column name where you want the Clear All button
(e.Column == radGridView1.Columns[
"Id"
])
e.CellElement =
ClearAllFiltersCell((GridViewDataColumn)e.Column, e.Row);