Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
775
XamDataGrid FieldChooser
posted

Hi,

When using the xamdatagrid field chooser, The datagrid is getting refreshed for each change in the chooser window. But I want to refresh the grid only after closing the field chooser window with multiple selected or deslected fields. Please help on this. I am using 2013.2 version.

Thanks,

Sreek

Parents
No Data
Reply
  • 16495
    Offline posted

    Hello Sreek,

    You can  remove the XamCheckEditors value binding from default style of FieldChooser and implement logic where  iterate through the Fields and set manually  IsVisible property to be equal to the IsChecked of  corresponding XamCheckEditor. In order to do that after closing the FieldChooser you can access the ToolWindow from FieldChooser visual tree and handle its Closing event.  You can get it  in FieldChooserOpening event of XamDataGrid. To do that you can add something like:


    private void xdg_FieldChooserOpening(object sender, Infragistics.Windows.DataPresenter.Events.FieldChooserOpeningEventArgs e)
    {
        ToolWindow win = Utilities.GetAncestorFromType(e.FieldChooser, typeof(ToolWindow), false) as ToolWindow;
        win.Closing += new System.ComponentModel.CancelEventHandler(WinClosing);
    }


    public void WinClosing(Object sender, EventArgs e)
    {
        FieldChooser fChooser = Utilities.GetDescendantFromType((sender as ToolWindow),typeof(FieldChooser), false) as FieldChooser;

        if (fChooser == null)
            return;

        var checkEditors = FindVisualChildren<XamCheckEditor>(fChooser).Where(edt => edt.IsVisible).ToList();

        for (int i = 0; i < fChooser.CurrentFields.Count; i++)
        {
            fChooser.CurrentFields[i].IsVisible = (checkEditors[i] as XamCheckEditor).IsChecked ?? false;
        }       
    }

    We ship the default styles in the DefaultStyles directory in the Infragistics folder. The full path for the styles for the FieldChooser should look something like :

    C:\Program Files (x86)\Infragistics\NetAdvantage <your version>\WPF\DefaultStyles\DataPresenter.

    The FieldChooser style is in the DataPresenterGeneric_Express.xaml file.

    I have attached simple sample application, where you can test the suggested approach. 
     
    Please let me know if you have any more questions.

    Sincerely,
    Zhivko
    Entry Level Software Developer

    FieldChooserRefresh.zip
Children