I need to raise the event when user select the Group icon(expand/collapse). i have implemented the this feature from below mentiond article.
http://www.telerik.com/community/forums/silverlight/gridview/radgridview-grouped-row-selected-event.aspx
But if i try to get the status of expand/collapse from parentGroupRow.IsExpanded when i click the Group icon, It is giving the wrong value . if group row is expanded then it return as "false" and if its collapse, it return as "true".
Can you please verify this.
Thanks
Balsuyambu
5 Answers, 1 is accepted
I was not able to reproduce the issue you specified and the code-snippet provided in the forum thread executes as expected. Thus in order to provide you with any solution, I would need more details about your application and more specifically about the exact way you are defining the OnGridMouseDown method.
Maya
the Telerik team
We have grid with group functionality and we need to raise the GroupedRowExpanded event to the user when expand/collapse the group. so i refer the article which i mentioned and did the implementation and mentioned below.
private void iGrid_GridMouseDown(object sender, MouseButtonEventArgs e)
{
if (this.IsGrouping)
{
var objSender = e.OriginalSource as FrameworkElement;
var gvrParent = objSender.ParentOfType<GridViewRow>();
var gvgrparent = objSender.ParentOfType<GridViewGroupRow>();
if (gvrParent == null && gvgrparent != null)
{
GridViewGroupRowExpandEventArgs args = new GridViewGroupRowExpandEventArgs()
{
Group = gvgrparent.Group,
Expanded = gvgrparent.IsExpanded
};
if (GroupedRowExpanded != null)
GroupedRowExpanded(
this, args);
}
}
}
if user expand the group, i get the gvgrparent.IsExpanded property value as False and if user collapse the group then True is returned.
I think GridMouseDown is fired first and then gvgrparent.IsExpanded property value change to true if group expanded.
Thanks
Balsuyambu
Basically, it is not recommended to use the GridViewGroupRowExpandEventArgs in such a way and raise any event like that. If you share more details about your scenario and requirements, I may be able to provide you with a more appropriate solution for your case.
Maya
the Telerik team
Thanks for your suggestion.
We need to expose the event to the user on group expand and collape. This is our requirement.
Is there any way to achieve the functionality
Please clarify
Thanks
Balsuyambu S.
It is more appropriate in your case to add custom events raised on expanding/collapsing group row. For example:
public event EventHandler GroupExpanded;public event EventHandler GroupCollapsed;private void OnGridMouseDown(object sender, MouseButtonEventArgs e){ if (this.playersGrid.IsGrouping) { var senderElement = e.OriginalSource as FrameworkElement; var parentRow = senderElement.ParentOfType<GridViewRow>(); var parentGroupRow = senderElement.ParentOfType<GridViewGroupRow>(); if (parentRow == null && parentGroupRow != null) { if(parentGroupRow.IsExpanded = true && this.GroupExpanded != null) { this.GroupExpanded(this, EventArgs.Empty); } else if(parentGroupRow.IsExpanded == false && this.GroupCollapsed != null) { this.GroupCollapsed(this, EventArgs.Empty); } } }}Thus you can correctly implement the logic you need.
Best wishes,
Maya
the Telerik team