AUTHOR: Eyup Yusein
DATE POSTED: September 28, 2018
DESCRIPTION
When you want your grid to return to its clean and tidy initial state, you can clear its applied settings manually. If you are using integration with RadPersistenceFramework and want to clear the grid state initially depending on some condition, you can call the method provided below using the following approach:
protected
void
Page_PreRender(
object
sender, EventArgs e)
{
if
(!IsPostBack)
ResetGridState(RadGrid1);
}
SOLUTION The method below demonstrates how you can clear the grid by resetting the state of the primary functionalities:
Button1_Click(
private
ResetGridState(RadGrid grid)
// Sorting
grid.MasterTableView.SortExpressions.Clear();
// Grouping
grid.MasterTableView.GroupByExpressions.Clear();
// Paging
grid.CurrentPageIndex = 0;
// Editing
grid.EditIndexes.Clear();
// Inserting
grid.MasterTableView.IsItemInserted =
false
;
// Filtering
foreach
(GridColumn column
in
grid.MasterTableView.RenderColumns)
column.CurrentFilterFunction = GridKnownFunction.NoFilter;
column.CurrentFilterValue =
string
.Empty;
column.AndCurrentFilterFunction = GridKnownFunction.NoFilter;
column.AndCurrentFilterValue =
// for CheckList and HeaderContext filtering
column.ListOfFilterValues =
null
grid.MasterTableView.FilterExpression =
// Refresh
grid.Rebind();
Resources Buy Try