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

how to hide filter on "Add Row" Click

2 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ajmal
Top achievements
Rank 1
ajmal asked on 25 Nov 2010, 08:20 AM
Hello All,

I having a RadGrid with Filter enabled. when one search base on some filter and then wants to add record (inline edit) then a row is visible and when add record it will disapper due to filter is not cleared.

when nofilter is applied the filter condition is disappers and adding record is fine.

Is there any way to do when some one click on "Add Row", then filter condition is removed???

Please also check attached screen....

I tried below code, not works for me..

protected

 

void grdDelegation_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

try

 

{

hdnDelegationCommandName.Value = e.CommandName;

 

switch (e.CommandName)

 

{

 

case RadGrid.EditCommandName:

 

hdnDelegationGridAddUpdate.Value =

"2";

 

 

if (grdDelegation.MasterTableView.IsItemInserted)

 

{

e.Canceled =

true;

 

}

 

break;

 

 

case RadGrid.InitInsertCommandName:

 

 

//Pair filterPair = (Pair)e.CommandArgument;

 

 

//TextBox filterBox = (e.Item as GridFilteringItem)[filterPair.Second.ToString()].Controls[0] as TextBox;

 

 

//filterBox.Text = "";

 



2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Nov 2010, 10:40 AM
Hello Ajmal,

Try the following code snippet to clear the filters when inserting a record.

C#:
protected void grdDelegation_PreRender(object sender, EventArgs e)
    {
        if (grdDelegation.MasterTableView.IsItemInserted)
        {
           foreach (GridColumn column in grdDelegation.MasterTableView.Columns)
            {
                column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                column.CurrentFilterValue = string.Empty;
            }
            grdDelegation.MasterTableView.FilterExpression = string.Empty;
            grdDelegation.MasterTableView.Rebind(); 
        }
    }

Thanks,
Princy.
0
ajmal
Top achievements
Rank 1
answered on 25 Nov 2010, 11:19 AM
thanks a lot Princy...
Tags
Grid
Asked by
ajmal
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
ajmal
Top achievements
Rank 1
Share this question
or