I am using version 2011.1.516.1040 of the gridview.
9 Answers, 1 is accepted
Do you have some code showing the issue? How exactly you've added sorting - are you using ColumnSortDescriptor?
All the best,Vlad
the Telerik team
.
.
.
ResetDescriptors();
.
.
.
// here I add columns to the grid dynamically
// NavbarNode contains information on where to load data from and how to display it
i = 0;
foreach
(var col
in
NavbarNode.Columns)
{
GridViewDataColumn column =
new
GridViewDataColumn();
column.Header = col.HeaderTitle;
column.CellTemplate = CellTemplateList[i];
column.MinWidth = col.MinWidth;
ConfigureColumnDataBinding(i, col, column);
GridView.Columns.Add(column);
i++;
}
.
.
.
//
//
private
void
ConfigureColumnDataBinding(
int
columnIndex, ColumnInfo col, GridViewDataColumn column)
{
column.DataMemberBinding =
new
System.Windows.Data.Binding(
"<Member path>"
);
ConfigureColumnSorting(columnIndex, col, column);
ConfigureColumnGrouping(columnIndex, col, column);
/* this function follows the same paradigm as the configure coumn sorting function */
}
private
void
ConfigureColumnSorting(
int
columnIndex, ColumnInfo col, GridViewDataColumn column)
{
column.IsSortable =
true
;
if
(NavbarNode.SortInfo !=
null
)
{
var srtc = from sc
in
NavbarNode.SortInfo
where (sc.ColumnIndex - 1) == columnIndex
select sc;
int
CountOfSortColumns = srtc.Count();
if
(CountOfSortColumns > 0)
{
if
(CountOfSortColumns > 1)
{
throw
new
InvalidOperationException(
"Cannot have more than one sort column reference to a single column."
);
}
else
{
SortColumn srtcol = srtc.Single();
// Add a sort descriptor
SortDescriptor sd =
new
SortDescriptor();
sd.Member =
"<Member path>"
;
sd.SortDirection = (srtcol.SortDirection == SortDirection.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending);
GridView.SortDescriptors.Add(sd);
}
}
}
}
//
// Here I have to add exception swallowing code because I get exceptions a lot of times when I clear the group descriptors
private
void
ResetDescriptors()
{
try
{
if
(GridView.GroupDescriptors !=
null
&& GridView.GroupDescriptors.Count > 0)
{
GridView.GroupDescriptors.Clear();
}
}
catch
(Exception ex) { }
try
{
if
(GridView.SortDescriptors !=
null
&& GridView.SortDescriptors.Count > 0)
{
GridView.SortDescriptors.Clear();
}
}
catch
(Exception ex) { }
}
I have tested your scenario that the Sort indicator is not visible. I could reproduce this behavior on the second time when I apply Sorting without clearing the SortDescriptors already added. From the snippet of code that you have provided I can see that you call the ResetDescriptors() method, but I am not sure if you call it before every user click on a navigation bar item.
I have prepared a sample project where you may review how I have test. As well you may see that it is working alright when I call ResetDescriptors().
If you cannot get the Sorting indicator show appropriately, could you please change my project so that it has the wrong behavior. This way we could investigate it further.
Didie
the Telerik team
Please see support ticket at http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=429728. I will post the description below again.
==========================
Hello Didie,
1. Yes, I call ResetDescriptors every time the user clicks on the navigation bar item.
2. Please find the attached solution. I have changed the sort order of the columns depending on the column index but you will notice that it only shows all columns sorted in one direction.
I have posted an answer to the support ticket that you have opened. It would be better to continue our dialogue via support tickets.
I am closing this forum thread now. Thank you.
Didie
the Telerik team
I am building a grid in code. Adding my columns. Adding my data.
When I add the sorts or filters, the grid values are changed as expected; however, the grid UI does not ever indicate what the sorts or filters are if I set them from code. I am setting everything in the datacontextchanged event.
I would like to know more about what was happening with this but I cannot see what is in the support ticket.
Was there ever a resolution? Is there some method I can call on the grid to get the indicators to display if they are set in code?
I would recommend you to check Programmatic Sorting and Programmatic Filtering help topics. Let me know if you have additional questions.
Regards,
Yordanka
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
I re read it all again and still do not see any indication that there is a way to update the UI to show that I have changed the filters or sorts programatically.
Am I correct in that conclusion that the UI does not at this time ever know that the SortDescriptors collection was modified unless the collection was modified because the header was clicked?
What I NEED is for the sorting to be set in code and then the header to be updated to show the sorting. From all I read, it does not seem that the code allows that at this time.
I am attaching a working demo. Please give it a try and let me know if you have additional questions.
Regards,
Yordanka
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>