氚云代码-列表使用

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);
    }
}

 

posted @ 2021-08-26 17:18  山君与见山  阅读(803)  评论(0编辑  收藏  举报