Catch Event Enter When FilterChanged RadGrid

4 posts, 0 answers
  1. ALED
    ALED avatar
    18 posts
    Member since:
    Nov 2014

    Posted 30 Jun Link to this post

    Hello all,

    i have issue when filtering column, actually i want reoad my datasource when filterChanged, bbuut filterchanged always return before i completely what i type

     

    Ex , when i wan filter By : " Data", D first enter in filterChanged event, i am really just need completely like " Data"

    so i think if i can catch event enter in FilterChanged event it solve my issue, tell me how its work?

    this below my snippet code :

    private void RadGridMsHost_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
    {

    // i want use code like this, how to catch event enter in this section

    if(xxx = enter)
        FillRadGrid();
    }

    Please fast response,

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 01 Jul Link to this post

    Hello Aled,

    Thank you for writing. 

    There are two events that are raised when the data in the RadGridView is filtered. The first one is the FilterChanging event and it is raised before the data is filtered. The second one is the FilterChanged event which is raised after the data is filtered. Each entered char in the filter cell triggers the filtering functionality. This is by design. However, if you need to reload data when the filter criterion is completely entered, I would recommend you to handle the CellEndEdit event which is fired once the user commits the editor's value by pressing Enter key. Here is a sample code snippet:
    private void radGridView1_CellEndEdit(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        if (e.Row is GridViewFilteringRowInfo)
        {
          //reload data
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. ALED
    ALED avatar
    18 posts
    Member since:
    Nov 2014

    Posted 01 Jul in reply to Dess Link to this post

    Dear Jeff,

    thanks for your solustion, it done, but i have a problem whe removing filter DropDown,

    i want remove filter operator like : is null, custom, and no filter.

    How to remove operator by name Id ? i dont know, so i remove by index.

    and i used this code on event ContextMenuOpeningEventArgs :

     private void DeleteFilterOperator(ContextMenuOpeningEventArgs e)
            {
                try
                {
                    e.ContextMenu.Items.RemoveAt(0);
                    e.ContextMenu.Items.RemoveAt(6);
                    e.ContextMenu.Items.RemoveAt(6);
                    e.ContextMenu.Items.RemoveAt(6);
                }
                catch(Exception ex)
                {
                    RadMessageBox.Show(ex.Message);
                }
            }

    a problem come when i right click on gridview index was out of range ,

    may question is : How to remove filter operator without event ContextMenuOpeningEventArgs ?

    please fast response, thanks.

     

     

  5. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 04 Jul Link to this post

    Hello Aled,

    Thank you for writing back. 

    The ContextMenuOpening event is the appropriate solution for customizing the displayed items. You can check the ContextMenuOpeningEventArgs.ContextMenuProvider before removing the items. Please refer to the following code snippet: 
    private void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
    {
        GridFilterCellElement filterCell = e.ContextMenuProvider as GridFilterCellElement;
        if (filterCell != null)
        {
            foreach (RadItem item in e.ContextMenu.Items)
            {
                if (item.Text == "Is null")
                {
                    item.Visibility = ElementVisibility.Collapsed;
                }
            }
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top