如何设置默认的排序上DevEx preSS的GridView [英] How to set the default Sort on a DevExpress GridView

查看:253
本文介绍了如何设置默认的排序上DevEx preSS的GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET中的WinForm,DevEx preSS的GridControl / GridView控件绑定的数据集,如何指定默认的排序顺序?是,用于当没有可见的GridColumn用SortOrder的所述一个

On .net WinForm, DevExpress's GridControl/GridView bound on a DataSet, how to specify the default sort order? The one that is used when there is no visible GridColumn with a SortOrder.

在默认情况下,我对我的藏DateTimeStamp的GridColumn视图设置排序。当然用户overrided,如果用户点击一个列。 用户可以清除排序使用的列或通过单击列,而pressing控制键菜单。如果这样做,行不再被排序(或者通过PK?),而我希望他们通过DateTimeStamp排序。

By default, I have set a sorting on the view on my hidden DateTimeStamp GridColumn. It is of course overrided by user if user click on a column. User can "Clear Sorting" using the menu on column or by clicking on a column while pressing the Control key. When doing that, Rows are not sorted anymore (or maybe by PK?) while I would like them sorted by DateTimeStamp.

你知道吗?也许插上code时通知用户清除排序?我可以GridView.PopupMenuShowing和GridStringId.MenuColumnClearSorting发挥处理用户点击的菜单情况。但它不处理的控制+单击的情况。

Any idea? Maybe by plugging code to be notified when user "Clear Sorting"? I can play with GridView.PopupMenuShowing and GridStringId.MenuColumnClearSorting to handle the user-click-on-menu case. But it does not handle the case of Control+click.

有人曾经达到了同样的问题,发现一个(简单的)解决方案?

Has someone meet the same problem and found a (simple) solution?

推荐答案

如果我是你,我会根据所需的列网格的数据源进行排序。在这种情况下,如果GridView的挑选条件是由终端用户清零,数据将被显示在由你的数据源所指定的顺序

If I were you, I would sort the grid's DataSource based on the required column. In this case, if the gridView's sorting condition is cleared by the end-user, data will be displayed in the order specified by your DataSource.

更新 这里是code这应该为你工作:

UPDATE here is the code which should work for you:

DataView dv = yourDataTable.DefaultView;
dv.Sort = "SomeField";
gridControl.DataSource = dv;

此外,一起来看看下面的MSDN文章:

Also, take a look at the following MSDN article :

DataView.Sort物业

这篇关于如何设置默认的排序上DevEx preSS的GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆