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

Catch Event Enter When FilterChanged RadGrid

3 Answers 464 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ALED
Top achievements
Rank 1
ALED asked on 30 Jun 2016, 11:01 AM

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,

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Jul 2016, 09:37 AM
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.
0
ALED
Top achievements
Rank 1
answered on 02 Jul 2016, 03:10 AM

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.

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Jul 2016, 12:15 PM
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.
Tags
GridView
Asked by
ALED
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
ALED
Top achievements
Rank 1
Share this question
or