• FineUI Grid 缓存列显示隐藏状态


    当列表字段过多时,需要隐藏掉一些,但是再次打开页面又显示出来了,FineUI没有提供缓存功能,那么自己动手,打开【ext-part2.js】找到

    “if (Ext.grid.column.RowNumberer)”这里添加一个if代码如下

    if(Ext.grid.header.Container){
         Ext.override(Ext.grid.header.Container,{
                      onColumnCheckChange:function(checkItem, checked){
                            var header =Ext.getCmp(checkItem.headerId);
                            header[checked ?'show':'hide']();                        
                               F.customEvent("HeaderSelectedEven:id="+checkItem.headerId+";state="+checked+";grid="+this.grid.id);                        
                            }
                      });
    }

    效果是这样的

    然后在页面的load事件里写

    下面我们看WebBase里面的代码

            /// <summary>
            /// 功能描述:保存dgv隐藏表头id
            /// 作  者:huangzh
            /// 创建日期:2015-11-20 14:16:06
            /// 任务编号:
            /// </summary>
            /// <param name="strPageName">strPageName</param>
            /// <param name="strDgvName">strDgvName</param>
            /// <param name="strValues">strValues</param>
            public static void SaveDGVHideComs(string strPageName, string strDgvName, string strValues)
            {
                HttpCookie cookie = new HttpCookie(strPageName + "_" + strDgvName);
                cookie.Expires = DateTime.Now.AddMonths(12);
                cookie.Value = strValues;
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
    
            /// <summary>
            /// 功能描述:获取DGV隐藏表头id
            /// 作  者:huangzh
            /// 创建日期:2015-11-20 14:15:55
            /// 任务编号:
            /// </summary>
            /// <param name="strPageName">strPageName</param>
            /// <param name="strDgvName">strDgvName</param>
            /// <returns>返回值</returns>
            public static string GetDGVHideComs(string strPageName, string strDgvName)
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies[strPageName + "_" + strDgvName];
                if (cookie != null)
                {
                    return cookie.Value;
                }
                else
                {
                    return "";
                }
            }
    
            /// <summary>
            /// 功能描述:检查DGV隐藏表头
            /// 作  者:huangzh
            /// 创建日期:2015-11-20 14:15:34
            /// 任务编号:
            /// </summary>
            /// <param name="strPageName">strPageName</param>
            /// <param name="strDgvName">strDgvName</param>
            /// <param name="streventArgument">streventArgument</param>
            public static void CheckDGVHideComs(string strPageName, string strDgvName, string streventArgument)
            {
                if (streventArgument.StartsWith("HeaderSelectedEven:"))
                {
                    string strValues = streventArgument.Substring("HeaderSelectedEven:".Length);
                    string[] values = strValues.Split(';');
                    string strid = values[0].Split('=')[1];
                    string strstate = values[1].Split('=')[1];
                    string strDgvIds = values[2].Split('=')[1];
                    string[] names = strDgvIds.Split('_');
                    if (strDgvName == names[names.Length - 1])
                    {
                        string strValue = GetDGVHideComs(strPageName, strDgvName);
                        List<string> lstValues = strValue.Split(',').ToList();
                        if (strstate.ToLower() == "true")
                        {
                            if (lstValues.Contains(strid))
                            {
                                lstValues.Remove(strid);
                            }
                        }
                        else
                        {
                            if (!lstValues.Contains(strid))
                            {
                                lstValues.Add(strid);
                            }
                        }
    
                        strValue = string.Join(",", lstValues);
                        SaveDGVHideComs(strPageName, strDgvName, strValue);
                    }
                }
            }
    
            /// <summary>
            /// 功能描述:设置dgv隐藏表头
            /// 作  者:huangzh
            /// 创建日期:2015-11-20 14:20:11
            /// 任务编号:
            /// </summary>
            /// <param name="dgv">dgv</param>
            /// <param name="strPageName">strPageName</param>
            public static void SetDGVHideCom(FineUI.Grid dgv, string strPageName)
            {
                string strValue = GetDGVHideComs(strPageName, dgv.ID);
                if (!string.IsNullOrEmpty(strValue))
                {
                    dgv.HiddenColumns = strValue.Split(',');
                }
            }

    代码就这么多,我们看下效果吧

  • 相关阅读:
    87后的我
    meta标签中的httpequiv属性
    System.IO.Directory.GetCurrentDirectory与System.Windows.Forms.Application.StartupPath的用法
    递归方法重现
    实现控件的随意拖动
    Sql Server 2005 如何自动备份数据库
    用C#打开Windows自带的图片传真查看器
    配置SQL Server2005以允许远程访问
    Gridview控件有关的一些设置
    Add the Child Pane to Root.plist in the setting.bundlle
  • 原文地址:https://www.cnblogs.com/bfyx/p/5488410.html
Copyright © 2020-2023  润新知