I am having a terrible time expanding grid details. I've looked through the documentation, and message boards (this seems to be a common theme), but nothing has worked so far. Here's exactly what I want:
Forget that last line; my issue here is that setting SelectedItem doesn't do anything. Eventually I decided that something inside Telerik's code was still processing something and I split it up into a new threaded delegate:
This is a terrible solution because it uses a sleep, but it does FINALLY set the row. Then I began working on expanding the row details:
Finally this worked and the grid row gets expanded. Inside this grid row's details is another RadGridView. I need to select a specific item here, and scroll it into view. Here's what I am trying:
The issue above is that "details" is always null. The inner content of the grid has not yet rendered.
Can't I make Telerik render it's grid synchronously in my method so that setting the item source sets up the grid before execution in my method continues? Or so that expanding the row sets up the detail template contents before that execution continues? If not, how can I ensure that it updates the details grid before I attempt to set that row?
gridView.ItemsSource = orgList;
gridView.SelectedItem = orgList[0];
//// gridView.rows[0].Expand(); // <-- Yes, I know this doesn't exist, but pretty please add it.
Forget that last line; my issue here is that setting SelectedItem doesn't do anything. Eventually I decided that something inside Telerik's code was still processing something and I split it up into a new threaded delegate:
gridView.ItemsSource = orgList;
Action a =
delegate
{
gridView.SelectedItem = orgList[0];
};
Thread.Sleep(100);
App.Current.Dispatcher.Invoke(a,
null
);
This is a terrible solution because it uses a sleep, but it does FINALLY set the row. Then I began working on expanding the row details:
gridView.RowDetailsVisibilityMode = GridViewRowDetailsVisibilityMode.Visible;
gridView.ItemsSource = orgList;
Action a =
delegate
{
gridView.SelectedItem = orgList[0];
gridView.UpdateLayout();
var row = gridView.ItemContainerGenerator.ContainerFromItem(gridView.SelectedItem)
as
GridViewRow;
if
(row !=
null
) {
row.DetailsVisibility = Visibility.Visible;
row.IsExpanded =
true
;
}
};
Thread.Sleep(100);
App.Current.Dispatcher.Invoke(a,
null
);
Finally this worked and the grid row gets expanded. Inside this grid row's details is another RadGridView. I need to select a specific item here, and scroll it into view. Here's what I am trying:
var row2 = row.ChildrenOfType<DetailsPresenter>().FirstOrDefault()
as
DetailsPresenter;
if
(row2 !=
null
) {
var details = row2.Content
as
RadGridView;
if
(details !=
null
) {
details.SelectedItem = obj2;
details.ScrollIntoView(obj2);
}
}
The issue above is that "details" is always null. The inner content of the grid has not yet rendered.
Can't I make Telerik render it's grid synchronously in my method so that setting the item source sets up the grid before execution in my method continues? Or so that expanding the row sets up the detail template contents before that execution continues? If not, how can I ensure that it updates the details grid before I attempt to set that row?