Hello everyone,
we have the following use case: a RadGridView with a Details section where both, the row and the details section has editable contents. If someone changes a property (either in a cell or in a control inside the details section) we need to defer sorting actions of the rad grid view in order to prevent the current item to be sorted "out of scope". This happens if you have a lot of items, sort by property 1 ascending, then change the value of "A" to "Z" (which re-sorts the current item to the end of the list).
We tried hooking up to sorting event and set the cancel flag to "false" but it is not called if you the cell is commited on focus lost. We tried also to set ActionOnLostFocus to none, but after clicking on a empty region inside the details element (i.e. not a button) the current cell is committed and the gridview re-sorts itself.
Any advise how to prevent the grid to automatically sort our current selected item out of view?
Example:
Code behind:
The output "Sorting called" is only shown if a user sorts the column, but if the grid itself re-sorts it this text is not printed and therefore can't be canceled.
Version: RadControls for WPF Q1 2011
Thanks in advance,
Christian
we have the following use case: a RadGridView with a Details section where both, the row and the details section has editable contents. If someone changes a property (either in a cell or in a control inside the details section) we need to defer sorting actions of the rad grid view in order to prevent the current item to be sorted "out of scope". This happens if you have a lot of items, sort by property 1 ascending, then change the value of "A" to "Z" (which re-sorts the current item to the end of the list).
We tried hooking up to sorting event and set the cancel flag to "false" but it is not called if you the cell is commited on focus lost. We tried also to set ActionOnLostFocus to none, but after clicking on a empty region inside the details element (i.e. not a button) the current cell is committed and the gridview re-sorts itself.
Any advise how to prevent the grid to automatically sort our current selected item out of view?
Example:
<
telerik:RadGridView
Sorting
=
"Grid_Sorting"
x:Name
=
"Grid"
ActionOnLostFocus
=
"None"
AutoGenerateColumns
=
"False"
RowDetailsVisibilityMode
=
"VisibleWhenSelected"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
IsReadOnly
=
"False"
DataMemberBinding
=
"{Binding FormOfAddress}"
>
<
telerik:GridViewDataColumn.CellEditTemplate
>
<
DataTemplate
>
<
ComboBox
SelectedItem
=
"{Binding FormOfAddress}"
ItemsSource
=
"{Binding AvailableFormOfAddresses}"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellEditTemplate
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
<
telerik:RadGridView.RowDetailsTemplate
>
<
DataTemplate
>
<
Border
Background
=
"Red"
Width
=
"100"
Height
=
"100"
>
<
StackPanel
>
<!-- Clicking on this text commits the ComboBox and re-sorts the grid -->
<
TextBlock
Text
=
"{Binding FormOfAddress}"
/>
<!-- Clicking on this button does not commit the ComboBox -->
<
Button
Content
=
"Save"
/>
</
StackPanel
>
</
Border
>
</
DataTemplate
>
</
telerik:RadGridView.RowDetailsTemplate
>
</
telerik:RadGridView
>
Code behind:
private
void
Grid_Sorting(
object
sender, Telerik.Windows.Controls.GridViewSortingEventArgs e) {
Debug.WriteLine(
"Sorting called."
);
}
The output "Sorting called" is only shown if a user sorts the column, but if the grid itself re-sorts it this text is not printed and therefore can't be canceled.
Version: RadControls for WPF Q1 2011
Thanks in advance,
Christian