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

Moving sorted Nullable culumns!

3 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Erik Sundström
Top achievements
Rank 1
Erik Sundström asked on 23 Sep 2009, 09:54 AM
Hi,

When moving a sorted column bind to objects of nullable type (DateTime?, int? etc) i get an error. Is this a know bug?

Best regards
Erik

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 24 Sep 2009, 02:15 PM
Hello Erik,

Thank you for contacting us.

This was not a known issue and I was able to reproduce it thanks to the information that you provided. Unfortunately, the issue is at the very base level of RadGridView, so I cannot provide you with any specific time frame when it will be addressed.

I am updating your Telerik points for the report. If you have additional questions, feel free to contact me.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Erik Sundström
Top achievements
Rank 1
answered on 29 Sep 2009, 02:26 PM
Post this wo if you like:

void

 

dataGrid_ColumnIndexChanged(object sender, ColumnIndexChangedEventArgs e)

 

{

 

if (currentSortFieldList != null && currentNullableColumn != null && this.dataGrid.Columns[e.NewIndex] == currentNullableColumn)

 

{

 

// Apply the sorting again

 

 

foreach (GridSortField sortFiled in currentSortFieldList)

 

{

 

this.dataGrid.MasterGridViewTemplate.SortExpressions.Add(sortFiled);

 

}

}

}

 

GridViewDataColumn currentNullableColumn = null;

 

 

List<GridSortField> currentSortFieldList = null;

 

 

void dataGrid_ColumnIndexChanging(object sender, ColumnIndexChangingEventArgs e)

 

{

 

if (this.dataGrid.Columns[e.OldIndex].IsSorted){

 

 

// Enable to move sorted columns of nullable type

 

 

if (

 

 

this.dataGrid.Columns[e.OldIndex].DataType.IsGenericType

 

&&

this.dataGrid.Columns[e.OldIndex].DataType.GetGenericTypeDefinition() == typeof(Nullable<>)

 

)

{

 

// Save current data

 

currentNullableColumn =

this.dataGrid.Columns[e.OldIndex];

 

 

// Save current sorted fields

 

 

if (currentSortFieldList == null)

 

{

currentSortFieldList =

new List<GridSortField>();

 

}

 

else

 

{

currentSortFieldList.Clear();

}

 

foreach (GridSortField sortFiled in this.dataGrid.MasterGridViewTemplate.SortExpressions)

 

{

currentSortFieldList.Add(sortFiled);

}

 

// Remove sortexpressions as a work around to avoid known bug

 

 

this.dataGrid.MasterGridViewTemplate.SortExpressions.Clear();

 

}

}

}

0
Erik Sundström
Top achievements
Rank 1
answered on 29 Sep 2009, 02:27 PM
formattning not that nice but it works fine.

regards
Erik
Tags
GridView
Asked by
Erik Sundström
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Erik Sundström
Top achievements
Rank 1
Share this question
or