wince下的Melior.NTable使用-添加过滤器

   在wince和windows moble 开发中发现datagrid使用很不方便,项目中用到了第三方开源控件NTable,却发现这个控件是2004年国外开发的,使用资料及其稀少

现在共享下其开发方法:

下载源码后只需要在自己的数据源里面实现其

: INTableModel接口里面的方法即可

 

View Code
     class TestModel:INTableModel
    {
         #region ITableModel Members

         public  int GetRowCount()
        {
             return  10000;
        }

         public  int GetColumnCount()
        {
             return  4;
        }

         public  string GetColumnName( int columnIndex)
        {
             if (columnIndex ==  0)
                 return  " 序号 ";
             if (columnIndex ==  1)
                 return  " 供应商 ";
             if (columnIndex ==  2)
                 return  " 合同号 ";
             if (columnIndex ==  3)
                 return  " 单号 ";

             return  " Description ";
        }

         public Type GetColumnClass( int columnIndex)
        {
             if (columnIndex ==  0)
                 return  typeof( int);

             return  typeof (String);
        }

         public  bool IsCellEditable( int rowIndex,  int columnIndex)
        {
             return columnIndex ==  1;
        }

         public  object GetValueAt( int rowIndex,  int columnIndex)
        {
             if (columnIndex ==  0)
                 return rowIndex+ 1;
             if (columnIndex ==  1)
                 return  " 供应商 ";
             if (columnIndex ==  2)
                 return  " 合同号 ";
             if (columnIndex ==  3)
                 return  " 单号 ";

             return  " Tap for enter description ";
        }

         public  void SetValueAt( object aValue,  int rowIndex,  int columnIndex)
        {
           
        }

         public  object GetObjectAt( int rowIndex,  int columnIndex)
        {
             return  null;
        }

         public  event TableModelChangeHandler Change;

         #endregion
    }

 

GetColumnName方法可以返回每列的列名

 

GetValueAt可以把每个格子的数据返回

你可以把自己的数据源的数据绑定上去

 

下面是过滤器的实现

 

View Code
     public  class RequestListDataSource : INTableModel
    {
         #region ITableModel Members
         private EntityType _showType;
         private Collection<RequestListRequestListItem> _rows;
         private List<RequestListRequestListItem> _filterRows;

         public RequestListDataSource(RequestList data, EntityType type)
        {
            _showType = type;
            _rows =  new Collection<RequestListRequestListItem>();
            _filterRows =  new List<RequestListRequestListItem>();
             if (data !=  null)
            {
                 foreach ( var item  in data.RequestListItem)
                    _rows.Add(item);
            }
            _filterRows.AddRange(_rows);
        }

         public  int GetRowCount()
        {
             // RequestList aa;aa.RequestListItem [0].
             return _filterRows.Count;
        }

         public  int GetColumnCount()
        {
             if (_showType == EntityType.MaterialCKOutSelectListNum)
                 return  4;
             else
                 return  3;
        }

         public  string GetColumnName( int columnIndex)
        {
             string result =  "";
             if (columnIndex ==  0)
                result =  " 序号 ";

             if (_showType == EntityType.MaterialCKOutSelectListNum)
            {
                 if (columnIndex ==  1)
                    result =  " 供应商 ";
                 else  if (columnIndex ==  2)
                    result =  " 合同号 ";
                 else  if (columnIndex ==  3)
                    result =  " 单号 ";
            }
             else
            {
                 if (columnIndex ==  1)
                    result =  " 领用单位 ";
                 else  if (columnIndex ==  2)
                    result =  " 单号 ";
            }
             return result;
        }

         public Type GetColumnClass( int columnIndex)
        {
             if (columnIndex ==  0)
                 return  typeof( int);
             else
                 return  typeof(String);
        }

         public  bool IsCellEditable( int rowIndex,  int columnIndex)
        {
             return  false;
        }

         public  object GetValueAt( int rowIndex,  int columnIndex)
        {
             object result =  null;

             if (rowIndex >= _filterRows.Count)
                 return result;

             if (columnIndex ==  0)
                result = rowIndex +  1;
             if (_showType == EntityType.MaterialCKOutSelectListNum)
            {
                 if (columnIndex ==  1)
                    result = GetValueFromType(_filterRows[rowIndex].Vendor);
                 else  if (columnIndex ==  2)
                    result = GetValueFromType(_filterRows[rowIndex].Contract);   
                 else  if (columnIndex ==  3)
                    result = _filterRows[rowIndex].RequestNum;
            }
             else
            {
                 if (columnIndex ==  1)
                    result = GetValueFromType(_filterRows[rowIndex].Receiver);  
                 else  if (columnIndex ==  2)
                    result = _filterRows[rowIndex].RequestNum;
            }

             return result;
        }

         public  void SetValueAt( object aValue,  int rowIndex,  int columnIndex)
        {

        }

         public  object GetObjectAt( int rowIndex,  int columnIndex)
        {
             return  null;
        }

         public  event TableModelChangeHandler Change;

         #endregion

         public  void SelectFilter( int columnIndex,  string filter)
        {
             if (columnIndex <=  0)
                 return;
            Collection<RequestListRequestListItem> data;
             if ( string.IsNullOrEmpty(filter))
            {
                data = _rows;
            }
             else
            {
                data =  new Collection<RequestListRequestListItem>();
                 foreach ( var item  in _rows)
                {
                     if (_showType == EntityType.MaterialCKOutSelectListNum)
                    {
                         if (columnIndex ==  1)
                        {
                             if (GetValueFromType(item.Vendor).ToString().Contains(filter))
                                data.Add(item);
                        }
                         else  if (columnIndex ==  2)
                        {
                             if (GetValueFromType(item.Contract).ToString().Contains(filter))
                                data.Add(item);
                        }
                         else  if (columnIndex ==  3)
                        {
                             if (item.RequestNum !=  null && item.RequestNum.Contains(filter))
                                data.Add(item);
                        }
                    }
                     else
                    {
                         if (columnIndex ==  1)
                        {
                             if (GetValueFromType(item.Receiver).ToString().Contains(filter))
                                data.Add(item);
                        }
                         else  if (columnIndex ==  2)
                        {
                             if (item.RequestNum !=  null && item.RequestNum.Contains(filter))
                                data.Add(item);
                        }
                    }
                }
            }
            _filterRows.Clear();
            _filterRows.AddRange(data);

             if ( this.Change !=  null)
                 this.Change();
        }

         private  object GetValueFromType(EmbedAttrType type)
        {
             object result =  "";
             if (type !=  null && type.Value !=  null)
                result = type.Value;
             return result;
        }
    }

 

其中RequestListDataSource是自己的数据源

在初始化处将自己的数据源转换成

_rows

然后添加过滤方法SelectFilter(int columnIndex, string filter),将过滤后的数据添加到_filterRows,最后绑定的是_filterRows

由此实现了过滤数据作用

附源码

https://skydrive.live.com/redir?resid=3B411B3D816BE9A3!2751

转载于:https://www.cnblogs.com/sung/archive/2012/10/23/2735059.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园的建设目标是通过数据整合、全面共享,实现校园内教学、科研、管理、服务流程的数字化、信息化、智能化和多媒体化,以提高资源利用率和管理效率,确保校园安全。 智慧校园的建设思路包括构建统一支撑平台、建立完善管理体系、大数据辅助决策和建设校园智慧环境。通过云架构的数据中心与智慧的学习、办公环境,实现日常教学活动、资源建设情况、学业水平情况的全面统计和分析,为决策提供辅助。此外,智慧校园还涵盖了多媒体教学、智慧录播、电子图书馆、VR教室等多种教学模式,以及校园网络、智慧班牌、校园广播等教务管理功能,旨在提升教学品质和管理水平。 智慧校园的详细方案设计进一步细化了教学、教务、安防和运维等多个方面的应用。例如,在智慧教学领域,通过多媒体教学、智慧录播、电子图书馆等技术,实现教学资源的共享和教学模式的创新。在智慧教务方面,校园网络、考场监控、智慧班牌等系统为校园管理提供了便捷和高效。智慧安防系统包括视频监控、一键报警、阳光厨房等,确保校园安全。智慧运维则通过综合管理平台、设备管理、能效管理和资产管理,实现校园设施的智能化管理。 智慧校园的优势和价值体现在个性化互动的智慧教学、协同高效的校园管理、无处不在的校园学习、全面感知的校园环境和轻松便捷的校园生活等方面。通过智慧校园的建设,可以促进教育资源的均衡化,提高教育质量和管理效率,同时保障校园安全和提升师生的学习体验。 总之,智慧校园解决方案通过整合现代信息技术,如云计算、大数据、物联网和人工智能,为教育行业带来了革命性的变革。它不仅提高了教育的质量和效率,还为师生创造了一个更加安全、便捷和富有智慧的学习与生活环境。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值