Hello Team,
i am using Infragistics 15.2 and has implemented group by record presenter style and now want to check all the records and group by records on selection of checkbox in headerprefix area.
I have attached stylesheet and image that how I want.
Can you please help me with that?
I have referred Post. I want to ad checkbox top of all the group
Hi Vikram,
I took a look at your code and style and it looks like you already have the Checkbox displayed in ever group header. I also see that your style references some behaviors that were not provided so I'm not sure how much of this you have implemented. But if you have a behavior written then this should be an ok way to handle the Checkbox Checked event.
You can handle the event and then grab the GroupByRecord which is the DataContext for the Checkbox. With the GroupByRecord you can iterate through it's children and select the records as desired. GroupByRecord has a ChildRecords collection you can iterate over. And since you have bound the Checkbox to the Tag property of the record that should persist the check state as you scroll since the underlying GroupByRecords are not virtualized, just their UI elements.
Hello Andrew,
Thanks for the response, My problem is,
I have a checkbox in HeaderPrefixArea of xamdatagrid. I want to give Check all option to user. so if user checks the checkbox in XAMDataGrid HeaderPrefixArea, All group by records and its sub records should be selected.
I have highlighted the checkbox in image and also added code for checkbox behavior. I tried to replicate behavior code for header Checkbox but i am getting the method/data table I assigned to XAMDataGrid datacontext.
Below is the code for binding datagrid.
*************Code *****************
DataTable dtObsTree = obj_BL.FillChartedObservationRichTextBox(DocumentGUID, PatCareDocGUID, tTargetPatCareDocGUID);
dgCopy.DataContext = dtObsTree;
As you have seen, the DataContext for the Checkbox in the HeaderPrefixArea is not really useful for your requirement. I think a better option is to travel up the visual tree from the Checkbox and find the HeaderPresenter. From there you can get the HeaderRecord and then all the GroupByRecords underneath it. The behavior might look something like this:
public class GroupByCheckBoxBehavior_Header : Behavior<CheckBox>{ private HeaderRecord _header; public HeaderRecord Header { get { if (_header == null) { var presenter = (HeaderPresenter)Utilities.GetAncestorFromType(AssociatedObject, typeof(HeaderPresenter), false); _header = presenter.DataContext as HeaderRecord; } return _header; } } protected override void OnAttached() { AssociatedObject.Checked += AssociatedObject_Checked; AssociatedObject.Unchecked += AssociatedObject_Unchecked;
base.OnAttached(); }
private void AssociatedObject_Checked(object sender, RoutedEventArgs e) { if (Header.RecordManager.HasGroups) { foreach (var groupRecord in Header.RecordManager.Groups) { groupRecord.Tag = true; } } }
private void AssociatedObject_Unchecked(object sender, RoutedEventArgs e) { if (Header.RecordManager.HasGroups) { foreach (var groupRecord in Header.RecordManager.Groups) { groupRecord.Tag = false; } } }}
In the Infragistics.Windows.Utilities class there is a method called GetAncestorFromType which I use to traverse up the visual tree and find a specific element.