how to hide filter on "Add Row" Click

3 posts, 1 answers
  1. ajmal
    ajmal avatar
    57 posts
    Member since:
    Oct 2006

    Posted 25 Nov 2010 Link to this post

    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. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ajmal
    ajmal avatar
    57 posts
    Member since:
    Oct 2006

    Posted 25 Nov 2010 Link to this post

    thanks a lot Princy...
Back to Top