找回密码
 立即注册

QQ登录

只需一步,快速开始

hn007

新手上路

2

主题

4

帖子

44

积分

新手上路

积分
44
  • 40

    金币

  • 主题

  • 帖子

最新发帖
hn007
新手上路   /  发表于:2013-3-5 17:05  /   查看:5460  /  回复:5
首先我们开发的web应用。现在需要实现像excel那样可以随意筛选数据,如何实现。

5 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-3-5 17:45:00
沙发
Spread中可以通过以下代码来实现过滤操作:
  1.     FarPoint.Web.Spread.NamedStyle instyle = new FarPoint.Web.Spread.NamedStyle();
  2.     FarPoint.Web.Spread.NamedStyle outstyle = new FarPoint.Web.Spread.NamedStyle();
  3.     instyle.BackColor = Color.Yellow;
  4.     outstyle.BackColor = Color.Aquamarine;
  5.     FarPoint.Web.Spread.FilterColumnDefinition fcd = new FarPoint.Web.Spread.FilterColumnDefinition(1, FarPoint.Web.Spread.FilterListBehavior.SortByMostOccurrences | FarPoint.Web.Spread.FilterListBehavior.Default);
  6.     FarPoint.Web.Spread.FilterColumnDefinition fcd1 = new FarPoint.Web.Spread.FilterColumnDefinition(2);
  7.     FarPoint.Web.Spread.FilterColumnDefinition fcd2 = new FarPoint.Web.Spread.FilterColumnDefinition();
  8.     FarPoint.Web.Spread.StyleRowFilter sf = new FarPoint.Web.Spread.StyleRowFilter(FpSpread1.Sheets[0], instyle, outstyle);
  9.     sf.AddColumn(fcd);
  10.     sf.AddColumn(fcd1);
  11.     sf.AddColumn(fcd2);
  12.     FpSpread1.Sheets[0].RowFilter = sf;
复制代码
回复 使用道具 举报
hn007
新手上路   /  发表于:2013-3-6 08:58:00
板凳
好的,谢谢,但是有个问题,符合条件的筛选出来了,带了背景色,能不能把不符合条件控制不出来呢?就如excel一样。
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-3-6 17:38:00
地板
hn007 你好

该功能和Excel有些区别,Spread中是通过背景色等样式来区分过滤的数据。
回复 使用道具 举报
hn007
新手上路   /  发表于:2013-3-7 13:54:00
5#
貌似可以通过HideRowFilter实现吧
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-3-7 17:37:00
6#
貌似可以通过HideRowFilter实现吧
hn007 发表于 2013-3-7 13:54:00


多谢hn007提醒,代码如下:
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (!IsPostBack)
  4.         {
  5.             FarPoint.Web.Spread.FilterColumnDefinition fcd = new FarPoint.Web.Spread.FilterColumnDefinition(1, FarPoint.Web.Spread.FilterListBehavior.SortByMostOccurrences | FarPoint.Web.Spread.FilterListBehavior.Default);
  6.             FarPoint.Web.Spread.FilterColumnDefinition fcd1 = new FarPoint.Web.Spread.FilterColumnDefinition(2, FarPoint.Web.Spread.FilterListBehavior.Default);
  7.             FarPoint.Web.Spread.FilterColumnDefinition fcd2 = new FarPoint.Web.Spread.FilterColumnDefinition(3);
  8.             FarPoint.Web.Spread.HideRowFilter hf = new FarPoint.Web.Spread.HideRowFilter(FpSpread1.Sheets[0]);
  9.             hf.AddColumn(fcd);
  10.             hf.AddColumn(fcd1);
  11.             hf.AddColumn(fcd2);
  12.             FpSpread1.Sheets[0].RowFilter = hf;
  13.         }
  14.     }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部