When the user clicks on the column header to do a sort, I would like the sort to always come out the same way, even if the column (or columns) they clicked on do not have unique values.
If it helps, I have another column in the table that always has unique values. So if I could programmatically add that column at the end of the "sort column" list, that would solve the problem.
Hello,
I am following up to see if you have any further questions with this matter.
Bhadresh
Hi,
Based on the description you have provided the best approach is to cancel the column sorting on client side BeforeSortColumnHandler event. The following lines of code will sort the column based on the column Id.
The following lines of JavaScript will achieve the above described:
function UltraWebGrid1_BeforeSortColumnHandler(gridName, columnId){ if (columnId == "UltraWebGrid1_c_0_1") { return false; } else { return true; }}
Let me know if you have any further questions with this matter.
It is version 9.2.20092.2025. (Note that there is a support case on this - I presume you are working with the support group? Anyway, no one else has yet responded to the below information):
Here is what I have in my SortColumn event handler:
private void UltraWebGrid1_SortColumn(object sender, Infragistics.WebUI.UltraWebGrid.SortColumnEventArgs e) {Infragistics.WebUI.UltraWebGrid.SortedColsCollection sortedCols = UltraWebGrid1.Bands[0].SortedColumns;int cnt = sortedCols.Count;if (sortedCols.GetItem(cnt - 1).Key.ToString() != "Order") sortedCols.Insert(cnt, UltraWebGrid1.Bands[0].Columns.FromKey("Order"));return;}
When I click on a column I notice that I go through the code above, and it does seem to add the extra column into sortedCols. However, when I continue the code I get an Infragistics internal exception:
var col = this.Element.childNodes[0].childNodes[i];if (col.getAttribute("columnNo")){var colNo = parseInt(col.getAttribute("columnNo"));gs.Bands[0].Columns[colNo].Element = col; <-- Error indication on this line}
The error message is Bands.0.Columns[...] is nul or not an object.
I hope this example will help track down what is going on.
I have tested this behavior you described with service release of NetAdvantage 2009.2 (9.2.20092.2115). I was not able to see the behavior you described. Please test this with latest service release or let me know the version of NetAdvantage product you are using with service release if any so I may test. Let me know if you have any further questions.
I need to expand on this. I actually realized I could use BinaryTree for the default Sort Algorithm. So that "sort of" fixes part of the problem. But then, after I do the sort, and then change the page, and change the page back, the sorting is not the same. The sorted column itself is in order, the rest of the row does not retain its order.
In other words, the change page event seems to screw up Sort Stability, even if BinaryTree is used.