zoukankan      html  css  js  c++  java
  • 氚云代码-列表使用

    1.获取选定列表的对象

    2.修改数据标题,列名

    3.列表自定义筛选

    4.修改列表颜色

    using System;
    using System.Collections.Generic;
    using System.Text;
    using H3;
    
    public class D0017286997bef7c8704ed9ae1b3ebd1dad82d1_ListViewController: H3.SmartForm.ListViewController
    {
        public D0017286997bef7c8704ed9ae1b3ebd1dad82d1_ListViewController(H3.SmartForm.ListViewRequest request): base(request)
        {
        }
    
        protected override void OnLoad(H3.SmartForm.LoadListViewResponse response)
        {
            //修改颜色代码要放在OnLoad后面
            //
            base.OnLoad(response);
            foreach(Dictionary < string, object > data in response.ReturnData)
            {
                if(data["F0000002"] + string.Empty == "")
                {
                    data["F0000002"] = new H3.SmartForm.ListViewCustomCell(data["F0000002"] == null ? "--" : data["F0000002"].ToString(), H3.SmartForm.Color.Blue);
                } else
                {
                    data["F0000002"] = new H3.SmartForm.ListViewCustomCell(data["F0000002"] == null ? "--" : data["F0000002"].ToString(), H3.SmartForm.Color.Red);
                }
            }
        }
        //列表自定义筛选(只显示男)
        // protected override void OnInit(H3.SmartForm.LoadListViewResponse response) {
        //     H3.Data.Filter.Filter filter=new H3.Data.Filter.Filter();//构造过滤器
        //     H3.Data.Filter.And andMat=new H3.Data.Filter.And();//构造and匹配器
        //     andMat.Add(new H3.Data.Filter.ItemMatcher("F0000002",H3.Data.ComparisonOperatorType.Equal,"男"));//添加查询条件
        //     filter.Matcher=andMat;
        //     this.Request.Filter=filter;
        //     base.OnInit(response);
        //  }
        //修改列名
        // protected override void OnInit(H3.SmartForm.LoadListViewResponse   response)
        // {
        //     Dictionary < string, H3.SmartForm.ListViewColumn > columns=new Dictionary<string, H3.SmartForm.ListViewColumn>();
        //     foreach(string key in response.Columns.Keys)
        //     {
        //         if(key == "F0000001")//判断当前列的编码是否是F0000001
        //         {
        //             //将F0000001列的列名称改成 供应商信息
        //             H3.SmartForm.ListViewColumn newCol = new H3.SmartForm.ListViewColumn(
        //                 "F0000001",//列编码(对应控件编码)
        //                 "Name", //列名称
        //                 response.Columns[key].Visible,
        //                 response.Columns[key].Sortable,
        //                 response.Columns[key].Url,
        //                 response.Columns[key].Align,
        //                 response.Columns[key].IsLabel,
        //                 response.Columns[key].ShowMode
        //             );
        //             columns.Add("F0000001", newCol);
        //         }
        //         else
        //         {
        //             columns.Add(key, response.Columns[key]);
        //         }
        //     }
        //     response.Columns = columns;
        // }
        //修改数据标题(Name)
        // protected override void OnInit(H3.SmartForm.LoadListViewResponse   response)
        // {
        //     Dictionary < string, H3.SmartForm.ListViewColumn > columns=new Dictionary<string, H3.SmartForm.ListViewColumn>();
        //     foreach(string key in response.Columns.Keys)
        //     {
        //         if(key == "Name")//判断当前列的编码是否是F0000001
        //         {
        //             //将F0000001列的列名称改成 供应商信息
        //             H3.SmartForm.ListViewColumn newCol = new H3.SmartForm.ListViewColumn(
        //                 "Name",//列编码(对应控件编码)
        //                 "标题", //列名称
        //                 response.Columns[key].Visible,
        //                 response.Columns[key].Sortable,
        //                 response.Columns[key].Url,
        //                 response.Columns[key].Align,
        //                 response.Columns[key].IsLabel,
        //                 response.Columns[key].ShowMode
        //             );
        //             columns.Add("Name", newCol);
        //         }
        //         else
        //         {
        //             columns.Add(key, response.Columns[key]);
        //         }
        //     }
        //     response.Columns = columns;
        // }
        //修改排序列
    
    
        protected override void OnSubmit(string actionName, H3.SmartForm.ListViewPostValue postValue, H3.SmartForm.SubmitListViewResponse response)
        {
            //获取选择行idid
            if(actionName == "Init")
            {
                string[] objectId = (string[]) postValue.Data["ObjectIds"];
                if(objectId == null || objectId.Length == 0)
                {
                    response.Message = "请选择数据行";
                    return;
                }
                foreach(string item in objectId)
                {
                    //获取数据对象
                    H3.DataModel.BizObject biz = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Engine, "D0017286997bef7c8704ed9ae1b3ebd1dad82d1", item, false);
                    biz["F0000003"] = double.Parse("0" + biz["F0000003"]) + 1;
                    biz.Update();
                }
            }
            if(actionName == "Copy")
            {
                string[] objectId = (string[]) postValue.Data["ObjectIds"];
                foreach(string item in objectId) 
                {
                     //获取数据对象
                    H3.DataModel.BizObject biz = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Engine, "D0017286997bef7c8704ed9ae1b3ebd1dad82d1", item, false);
                    H3.DataModel.BizObject newbiz=new H3.DataModel.BizObject(this.Engine,this.Engine.BizObjectManager.GetPublishedSchema("D0017286997bef7c8704ed9ae1b3ebd1dad82d1"),this.Request.UserContext.UserId);
                    newbiz["F0000001"]=biz["F0000001"];
                    newbiz["F0000002"]=biz["F0000002"];
                    newbiz["F0000003"]=biz["F0000003"];
                    newbiz.Status=H3.DataModel.BizObjectStatus.Effective;
                    newbiz.Create();
                 }
            }
            base.OnSubmit(actionName, postValue, response);
        }
    }
  • 相关阅读:
    关于Python虚拟环境与包管理你应该知道的事
    你是否真的了解全局解析锁(GIL)
    谈谈装饰器的实现原理
    快速了解Python并发编程的工程实现(下)
    快速了解Python并发编程的工程实现(上)
    简单了解一下事件循环(Event Loop)
    为何你还不懂得如何使用Python协程
    一文搞懂Python可迭代、迭代器和生成器的概念
    源码分析Retrofit请求流程
    一份程序猿单词列表(updating)
  • 原文地址:https://www.cnblogs.com/H-Yan/p/15190673.html
Copyright © 2011-2022 走看看