Hi to All,
I would like to add one checkbox to every group header, and the handle its click or change event. In the event I must know a)what is the state of the checkbox and b) for what group it belongs to.
Thanks in advance
Hello Justin,
One option to add a checkbox to every group header of a XamDataGrid is to merge the default styles for the XamDataGrid and copy the GroupByRecordPresenter style into your MainWindow.xaml. In the GroupByRecordPresenter style, there is a StackPanel with its Orientation set to Vertical. This StackPanel contains a ContentControl and a GroupBySummariesPresenter.
If you set that StackPanel’s Orientation to Vertical and add a CheckBox to it, you can handle the Click event of that CheckBox in the code-behind. In that click event, you can use Utilities.GetAncestorFromType to obtain the GroupByRecordPresenter that the CheckBox sits in. Then, you can obtain the group by calling GroupByRecordPresenter1.Description. To get the state of the CheckBox, you can check the IsChecked property of it.
I have attached a sample application to demonstrate the above. To help you find where to place the CheckBox, I have placed a signature reading DSE-ANDREW directly above the StackPanel.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewDeveloper Support Engineer IInfragistics Inc.www.infragistics.com/support
Hi,
I have similar situation but i need to add few controls to the group by header area(Please see screenshots attached). The value of these controls should come via binding and also we have AllowGroupBy="False". The grouping is set in the code based on the data being binding to the grid.
Hello All,
I have put together a new and improved sample project that implements each of the three requirements mentioned above. I will section the description of each piece by the name of each person below:
Vikram: In order to do this, I would recommend utilizing the Tag property of the underlying GroupByRecord on the GroupByRecordPresenter. This is the DataContext of the GroupByRecordPresenter, and as such, the DataContext of everything in its template as well. The XamDataGrid.Records collection will contain these GroupByRecords, and so if you set the Tag to "false" on load, handle the Checkbox.Checked/Unchecked events on your HeaderPrefixArea checkbox, use the Infragistics.Windows.Utilities class as mentioned in the original response to this thread to get the XamDataGrid, and then loop through each GroupByRecord in the XamDataGrid.Records collection, you can set the Tag of each to correspond with the checked state of the checkbox.
Aziz: The GroupByRecord that serves as the DataContext to the GroupByRecordPresenter has a DataPresenter property that returns the XamDataGrid. From this, you can bind to DataPresenter.DataContext to get the DataContext of the grid, which I imagine would be your ViewModel. If your ViewModel has a property that references the command that you are looking to bind, you can bind to it in this way on the Button that would be placed in the GroupByRecordPresenter template.
Kumar: Similar to Aziz's requirement in this case, you can use the same type of binding to bind to a property on your ViewModel. This is demonstrated in the sample project as the Content of the Button is bound to a string property in the ViewModel.
I am attaching a sample project that demonstrates each of the three above requirements. I hope this helps.
XDGGroupByCheckBoxDemo.zip
Hello Andrew, I have a requirement bit similar but want to add button to the last column of the group by area . How can I achieve that? as adding to the beginning messes up the summary calculation alignment.
Thanks
Hello Sunil,
I am under the impression that by adding a button to the "last column" you are referring to placing the button after the header that in the above sample project reads <name> (X items). If this is incorrect, please let me know as the following is based upon that impression.
In order to do this, I would recommend taking a look at the sample project attached above. If you go into the GroupByRecordPresenterDictionary.xaml and look at the ControlTemplate for the GroupByRecordPresenter style, you will find a Checkbox, Button and ContentControl that all exist within a StackPanel oriented horizontally. If you place the Button after the ContentControl in the XAML, but still within that StackPanel, it will appear after the header text.
Hi andrew
I have a xamdata grid in that i need to add checkbox iam using infragictic version 10.3 .
below code iam using to add checkbox but nor working as expected
<igDP:UnboundField Label="CheckBox field" Name="chk"> <igDP:UnboundField.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamCheckEditor}"/> </igDP:UnboundField.Settings> </igDP:UnboundField>