The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi - I was looking improve the performance of sorting large sets of data and followed the instructions in the following forum post (using the referenced sample). http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=34771
It definitely speeds things up, but it is sorting my float column like strings even though i am setting the CellValueType to Double. When the GridRowSortItem does the compare, it''s of 2 objects and thus the sorting is incorrect.
Any suggestions or other samples on how i can propertly sort different data types?
ADAdministrator Syncfusion Team September 6, 2006 03:52 AM UTC
Hi Julie,
The GridControlSort browser sample shows you how to add header-click sorting to your grid. The header cell draws a sort icon to indicate that the column has been sorted in a particular direction.
Here is a path. [Instal drive]: \Program Files\Syncfusion\Essential Studio\4.3.0.0\windows\Grid.Windows\Samples\Quick Start\GridControlSort
Click the syncfusion Browser Sample=>Essetail Studio samples => GridSamples => QuickStart => GridControlSort
Let me know if this helps. Thanks, Haneef
JLJulie LevySeptember 6, 2006 05:09 PM UTC
Hi Haneef - Thanks for your quick response. The sample you are suggesting shows how to do custom sorting for a formula column and uses SortByColumn. I found SortByColumn to be very slow which is why i went with the other example which uses an Array sort. It doesn''t, however, recognize the cellvaluetypes when it does the compare. I found a way to do it by getting the cellvaluetype out using model indexing when building the array, storing it in the GridRowSortItem, and then checking it during the compare. (see code below) This has to be slowing things down so i was just wondering if there was a better way.
public struct GridRowSortItem : IComparable { public GridCellCollection row; public object sortValue; public Type valueType; #region IComparable Members
public int CompareTo( object obj ) { int iResult = 0; object val1 = sortValue; object val2 = obj != null ? ((GridRowSortItem)obj).sortValue : null; double double1 = 0; int int1 = 0; int int2 = 0; double double2 = 0;
if (ObjectIsNullOrEmpty( val1 ) && ObjectIsNullOrEmpty(val2)) return 0; else if (ObjectIsNullOrEmpty(val1)) return -1; else if (ObjectIsNullOrEmpty( val2 )) return 1; else { try { if (val1 is IComparable && val2 is IComparable) { if (valueType == typeof( Double )) { double1 = Convert.ToDouble(val1); double2 = Convert.ToDouble(val2); iResult = double1.CompareTo( double2 ); } else if (valueType == typeof( Int32 )) { int1 = Convert.ToInt32( val1 ); int2 = Convert.ToInt32( val2 ); iResult = int1.CompareTo( int2 ); }
I would like to know instead how can I keep the user from sorting the columns.
Sometimes the users need to have the data in the original sequence it is being displayed but some of them sort the data unintentionally and the printouts are messed out.
So, my question is, how to disable the sorting ability of the control.