Currently, the row details are shown when any cells in the row is selected. However, I would like to only show my row details only when cells in (eg column A &C) is selected and the row details are different when selecting cells in the same row (but in column A&C).
Thank you.
1 Answer, 1 is accepted
0
Dilyan Traykov
Telerik team
answered on 08 Oct 2019, 08:21 AM
Hi Jasmine,
You can achieve the desired result by handling the PreviewMouseLeftButtonDown event of the cells and setting the DetailsVisibility property of the parent row if the clicked cell belongs to the particular column. You can also set the DetailsTemplate of the row to a specific template based on the column.
this.GridView.CellLoaded += (s, e) =>
{
e.Cell.PreviewMouseLeftButtonDown += (sen, arg) =>
{
if (e.Cell.Column.Header.ToString() == "A")
{
(e.Cell.ParentRow as GridViewRow).DetailsVisibility = Visibility.Visible;
(e.Cell.ParentRow as GridViewRow).DetailsTemplate = App.Current.Resources["ATemplate"] as DataTemplate;
}
elseif (e.Cell.Column.Header.ToString() == "C")
{
(e.Cell.ParentRow as GridViewRow).DetailsVisibility = Visibility.Visible;
(e.Cell.ParentRow as GridViewRow).DetailsTemplate = App.Current.Resources["CTemplate"] as DataTemplate;
}
};
};
Alternatively, you can use the CurrentCellChanged event in a similar manner by accessing its arguments' NewCell property.
Please give these approaches a try and let me know if any of them works for you.
Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.Learn More.