I have a hierarchical XamDataGrid in which I wanted to collapse all the records in single click. I was wondering if that can be done by catching a right click event with a context menu on the expansion indicator.
Looking forward to hearing from you.
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I created a Style for the ExpansionIndicator and added XamContextMenu to it with two items. I also set their Command Properties to commands which expand and collapse all Records using XamDataGrid’s Records collection ExpandAll and CollapseAll methods. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Thank you for your help. It worked. But couldn't close context menu after the clicking on it's menuitem. I had to click some other place in the screen to close it.
Tried something like
(((parameter as ExpansionIndicator).TemplatedParent as RecordPresenter).DataPresenter as XamDataGrid).Focus();
XamDataGrid grid = ((parameter as ExpansionIndicator).TemplatedParent as RecordPresenter).DataPresenter as XamDataGrid;grid.RaiseEvent(new RoutedEventArgs(XamDataGrid.MouseDoubleClickEvent));
these didn't worked.
Awaiting your reply on this.
Could you please tell what vesrion of NetAdvantage yo uare using because I tested the sample against the latest service release of 13.1 (2155) and everything works as expected on my side?
I was working on NetAdvantage 12.1.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
I have pretty the same question: but I'd like to have an Expand button in the column's header (like Filter button). Is it possible to achieve?
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I copied the default Style of the HeaderPrefixArea and add an ExpansionIndicator to its Template. I also used Converter in order to control the visibility of the indicator, so it could be visible only in the first layout. You can feel free to organize the template as you want. Please let me know if this helps you or you have further questions on this matter.
Hi, I am facing a similar issue. However, your solution relies on the fact that the RecordSelectorLocation is not set to "None" because HeaderPrefixArea is right above that. If I have RecordSelectorLocation set to "None", the HeaderPrefixArea is not visible anymore (Please correct me if I am wrong here) In that case, how can I put the ExpansionIndicator for expand/collapse all rows right above the column where all other individual expansion indicators are without re-styling the HeaderPrefixArea? Is there a way to re-style the area above the column of all individual expansion indicators?
I am attaching a screenshot where the expand/collapse all indicator is in a different column (same column as RecordSelectorLocation) than those individual expand indicators. It would be nice if I could find a way so that they are all in the same column. So far I can't find any way to do that.
I would appreciate if you could provide some suggestions for doing that. Thanks.
I have been looking into your post and I can say that you are right that there is no HeaderPrefixArea, when there are no RecordSelectors, so I modified the sample I have attached before, so now it works as you want. Basically I handled the DataRecordPresenter's Loaded event and in the handler I check if it is the ultimate header record, if it is I get the expansion indicator inside its template and set its Visibility to Visible and handle its PreviewMouseLeftButtonDown event in order to be able to expand and collapse all records.
Thanks. But that is not exactly the requirement. I was trying to say there is one master "Expand/Collapse All" button at the top that is in HeaderPrefixArea (assuming RecordSelectorLocation is not "None") which is only in expanded state when all other individual rows' "Expand/Collapse" buttons (slave buttons) below it are in expanded state too.
My question is about how I can make it so that the master button is in the same column as the slave buttons when RecordSelectorLocation is "None" and HeaderPrefixArea is not visible anymore. As you can see in my previous attached screenshot, the "+" at the top is not in the same column as all other "+/-". The "+" on top is in HeaderPrefixArea, and the other "+/-" buttons below is in the "ExpansionIndicator" column (and I don't know what the technical name is for that column). Another question would be if I can re-template the area right above the "ExpansionIndicator" column.
I am thinking about setting RecordSelectorLocation to "LeftOfCellArea", and then re-template HeaderPrefixArea for the master and re-template all the RecordSelectors as ExpansionIndicator slave buttons. I am not sure if that will work yet as I am still trying, but looking for an easier and neater way out if there is any.
I combined the previous two sample in one. Now there are two XamDataGrids. The first one has selectors and the second one doesn't. Their expand all buttons are both aligned with the other expanders. I already explained how the two approaches work. The thing a I added to the one that has selectors is to set the ExpansionIndicator margin so it will be aligned.
Any thoughts how you could make "+/-" a three-state checkbox that would be synced with child rows? I.e. if you expand one of the rows it would change the state of "master +/-" button?
Are there any plans to add this as a normal built-in feature? Seams like something basic to have in the product of this scope.