SQL 排序顺序与 TreeList 排序顺序的差异
在我的 VB.NET 程序中,我使用 Devexpress TreeList v9.2。当我运行该程序时,我从存储过程填充 TreeList。
当我在 SQL Management Studio 中运行 SQL 过程时,我的数据会按照我想要的方式返回。例如
- 3
- 6
- 33
- 42
- 54
- 206
- 226
- 733
- 6633
然而,当我运行程序并使用存储过程中的相同结果填充 TreeList 时,我得到:
- 206
- 226
- 3
- 33
- 42
- 54
- 6
- 6633
- 733
你知道我可能做错了什么吗??
编辑:
我的存储过程中有一个“order by”。这就是为什么当我从 SQL Management Studio 中运行存储过程时,我得到了正确的顺序。 order by 将数字分解为子字符串(因为它们也可以包含字母),因此它看起来是按数字排序的。不知何故,TreeList 似乎将其视为字符串,而不是保持原始排序顺序。
编辑:
我创建了另一列包含数字数据,因此当我按此列升序对表格进行排序时,我的数据将看起来像我想要的那样。但即使我在属性中发送了 SortOrder,即使运行时网格的标题中出现了小三角形,它也不会排序。
已解决:
我通过调用以下方法解决了这个问题:
- tree.beginSort()
- 将我想要排序的列的排序索引设置为 0,将其他列设置为 -1:
tree.columns("colName ").SortIndex
- 将列的排序顺序设置为升序:
tree.columns("colName").SortOrder = SortOrder.Ascending
- tree.endsort()
Within my VB.NET program I am using a Devexpress TreeList v9.2. When I run the program I fill the TreeList from a stored procedure.
When I run the SQL procedure in SQL Management Studio my data is returned the way I want it. For example
- 3
- 6
- 33
- 42
- 54
- 206
- 226
- 733
- 6633
Yet when I run the program and fill the TreeList with the same results from the Stored Procedure I get:
- 206
- 226
- 3
- 33
- 42
- 54
- 6
- 6633
- 733
Do you know what I might be doing wrong??
EDIT:
I do have an 'order by' in my stored procedure. That is why I am getting the right order when I run the stored procedure from within the SQL Management Studio. The order by breaks up the number as substrings (as they could also contain letters) so it appears to be sorted numerically. Somehow it looks like the TreeList is resorting it as Strings rather than keeping it with the original sort order.
EDIT:
I created another column containing numeric data so when I sort the table by this column ascending my data would look how I want it. But even though I sent the SortOrder in the properties it wouldn't sort even though the little triangle appeared in the header of the grid when run.
SOLVED:
I solved this by calling:
- tree.beginSort()
- setting the sortindex to the column I want to sort by to 0 and the others columns to -1:
tree.columns("colName").SortIndex
- setting sortorder of my column to ascending:
tree.columns("colName").SortOrder = SortOrder.Ascending
- tree.endsort()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TreeList 的列绑定到字符串字段。在这种情况下,treeList 认为该列包含字符串值并将它们作为字符串进行排序。要更改此行为,请使用 XtraTreeList 提供的自定义排序方法。
The treeList's column is bound to a string field. In this case, treeList thinks that this column contains string values and sorts them as strings. To change this behavior, use the Custom Sorting approach provided by the XtraTreeList.