Hello! I am starting to use Telerik controls, and they work really well, but I am stuck with my GridView:
First of all, I am trying to sort it by the first column, with UniqueName="alarmas" when the user clicks in a button:
And it doesn't work, I am not sure if the Member property should be the UniqueName, or not.
My second trouble is that the itemsSource of my grid is an Observable Dictionary, and when a entry changes, it also changes in the gird ( it works fine) but the changes row goes to the last position, and I would like it to go to the first or to stay in place (ordered by the first column),
When I saw that I could not order the grid by adding a SortDescriptor, I thought about generating the same event that occurs when the user clicks in the row header of a column to order the grid by it's column value, so when the Dictionary changes, I could reorder the grid by executing this event, but I could not find anything about it.
Hope you can help me because it's very important for my project.
Thanks!
<
telerik:RadGridView
Name
=
"gridAlarm"
AutoGenerateColumns
=
"False"
EnableRowVirtualization
=
"True"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"PtNum"
DataMemberBinding
=
"{Binding Key}"
Width
=
"auto"
UniqueName
=
"alarmas"
/>
<
telerik:GridViewDataColumn
Header
=
"Timestamp"
DataMemberBinding
=
"{Binding Value.Timestamp}"
Width
=
"auto"
/>
<
telerik:GridViewDataColumn
Header
=
"Description"
DataMemberBinding
=
"{Binding Value.Description}"
Width
=
"auto"
/>
<
telerik:GridViewDataColumn
Header
=
"Comment"
DataMemberBinding
=
"{Binding Value.Comment}"
Width
=
"auto"
/>
<
telerik:GridViewDataColumn
Header
=
"Point"
DataMemberBinding
=
"{Binding Value.Ptname}"
Width
=
"auto"
/>
<
telerik:GridViewDataColumn
Header
=
"RTU"
DataMemberBinding
=
"{Binding Value.Rtu}"
Width
=
"auto"
/>
<
telerik:GridViewDataColumn
Header
=
"Category"
DataMemberBinding
=
"{Binding Value.Category}"
Width
=
"auto"
/>
<
telerik:GridViewDataColumn
Header
=
"Table"
DataMemberBinding
=
"{Binding Value.Dbname}"
Width
=
"auto"
/>
<
telerik:GridViewDataColumn
Header
=
"Field"
DataMemberBinding
=
"{Binding Value.Fldname}"
Width
=
"auto"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
First of all, I am trying to sort it by the first column, with UniqueName="alarmas" when the user clicks in a button:
private
void
radButton1_Click(
object
sender, RoutedEventArgs e)
{
gridAlarm.SortDescriptors.Add(
new
SortDescriptor()
{
Member =
"alarmas"
,
SortDirection = System.ComponentModel.ListSortDirection.Ascending
});
}
And it doesn't work, I am not sure if the Member property should be the UniqueName, or not.
My second trouble is that the itemsSource of my grid is an Observable Dictionary, and when a entry changes, it also changes in the gird ( it works fine) but the changes row goes to the last position, and I would like it to go to the first or to stay in place (ordered by the first column),
When I saw that I could not order the grid by adding a SortDescriptor, I thought about generating the same event that occurs when the user clicks in the row header of a column to order the grid by it's column value, so when the Dictionary changes, I could reorder the grid by executing this event, but I could not find anything about it.
Hope you can help me because it's very important for my project.
Thanks!