This is a migrated thread and some comments may be shown as answers.

Sort not working in new version

7 Answers 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Luc
Top achievements
Rank 1
Luc asked on 07 Mar 2011, 05:08 PM
We have installed the new version of the GridView and some bug/issues occurs.

1. If setting the items source before columns created (throw code), the list wont display the cell content (rows are empty)...
    (We fix this issus will setting the itemssource after...)

2. the sort is not woking... (wont change the result) (this is not fixed for us..)

Version working : 2010.3.1110.35
Not working : 2010.3.1314.40

We have put back the old version and its working..

Any clues...

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 07 Mar 2011, 05:11 PM
Hi,

 Can you provide more info how the grid is created/bound, what kind of collection you've used, etc?

Kind regards,
Vlad
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Luc
Top achievements
Rank 1
answered on 07 Mar 2011, 05:24 PM

Since the columns are "User Defined" this is how I do this..

Note that we use an Inherited class of the RadGridView

1. clear the columns, group, and SortDescription
            this.Columns.Clear();
            this.Items.GroupDescriptions.Clear();
            this.Items.SortDescriptions.Clear();

2.I Iterate throw the columns to add..  (see code below...)

3.I Set the items source that is a ICollectionView (our implementation ...)

var itemColumn = pair.ColumnDefinition;
 
string path = DataBindingHelper.GetBindingPath(itemColumn.ColumnName, collectionType);  // ex: CustomerId
 
bool isImage = (pair.ColumnDefinition.BusinessEntityInfo == null ?
                                itemColumn.ColumnType == typeof(byte[]) :
                                pair.ColumnDefinition.BusinessEntityInfo.DynamicControlCaptureMode == DynamicControlCaptureMode.Image);
bool isNum = false;
GridViewBoundColumnBase col;
if (isImage)
{
    col = new Telerik.Windows.Controls.GridViewImageColumn();
    col.IsGroupable = false;
    col.IsSortable = false;
    col.IsFilterable = false;
}
else
{
    isNum = TypeUtility.IsNumericType(itemColumn.ColumnType);
    col = new GridViewDataColumn();
    col.IsGroupable = true;
    col.IsSortable = true;
    col.IsFilterable = true;
    col.ShowFieldFilters = false;
 
    // For traduction..
    var fil = new MaxFilteringControl(itemColumn, pair.Process == null ? ApplicationBase.CurrentUser : pair.Process.User);
    col.FilteringControl = fil;
 
}
// For design perpose...
MaxDataGridHelper.SetColumnDefinition(col, itemColumn);
col.DataMemberBinding = new Binding(path) { Mode = BindingMode.OneWay };
col.Header = itemColumn.Label;
 
if (itemColumn.Width > 0)
    col.Width = itemColumn.Width;
col.IsVisible = itemColumn.ShowInList; var coldef = pair.ColumnDefinition;
/... some code removed for clarity.../
if (!isImage && col.IsVisible && itemColumn.ColumnType != null && itemColumn.ColumnType.IsEnum) {     col.DataMemberBinding.Converter = MaxDataGridHelper.ObjectCaptionConverter;     col.DataMemberBinding.ConverterParameter = itemColumn.ColumnType; } else if (!isImage && col.IsVisible && (!string.IsNullOrEmpty(itemColumn.DisplayFormat) || isNum || itemColumn.ColumnType == typeof(DateTime))) {     if (isNum)         col.TextAlignment = TextAlignment.Right;     if (!string.IsNullOrEmpty(itemColumn.DisplayFormat))         col.DataFormatString = itemColumn.DisplayFormat;     else if (itemColumn.ColumnType == typeof(DateTime))         col.DataFormatString = "d"; }
// "this" is the inherited class definition this.Columns.Add(col);
0
Vlad
Telerik team
answered on 08 Mar 2011, 08:16 AM
Hello,

 With our Q3 2010 Sp1 the grid will let ICollectionView to sort if the collection CanSort is true. Can you check your code to see what is going on?

Regards,
Vlad
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Luc
Top achievements
Rank 1
answered on 16 Mar 2011, 07:10 PM
The source (ICollectioView.CanSort) return true

see the screen attached...
0
Yavor Georgiev
Telerik team
answered on 16 Mar 2011, 09:05 PM
Hello Luc,

 Can you please verify that your implementation of ICollectionView receives SortDescriptions from the RadGridView when the user sorts on a column?

Kind regards,
Yavor Georgiev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Luc
Top achievements
Rank 1
answered on 16 Mar 2011, 10:07 PM
yes. the sort description is added

see screen shot..

I did try a test, create my own column, override your CanSort() to see the real value (see sort1.png)
Also attach to the "Sorted Event" to try "grid.Items.Refresh()..." and check properties values (see sort2.png)

Note that the same code work with the version 2010.3.1110.35 but not with the lastest (2011.1.0315.40) neither the previous..


I did try several thing, using or not the dispatcher, setting back the items source..
...
Also note that everything is done by code (not xaml) since this is user defined...
Also, with this version, if I create the column and set the items source (it display the columns ok) but if I do the Itemssource and columns after, wrong display (see columns1 and 2.png) I Can send you a video (more explicite..)

Thank
0
Yavor Georgiev
Telerik team
answered on 17 Mar 2011, 03:33 AM
Hi Luc,

 Would it be possible for you to send the code of your ICollectionView implementation? You can either paste it as a code snippet in this thread, or open a separate support ticket and attach it there. Thanks.

All the best,
Yavor Georgiev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Luc
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Luc
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Share this question
or