开发者学堂课程【低代码氚云应用开发课程:氚云丨开发课— 07 列表的常见使用方法】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/894/detail/14284
氚云丨开发课— 07 列表的常见使用方法
列表的常见使用方法
1.获取列表勾选的行
protected override voha on[oad(3.SmartForm.LoadListviewResponse
2.字段颜色的修改
response)
base.OnLoad(response);
string , isFormControl = this.Request["isFormControl"]== null ?
"": this.Request["isFormcontrol"].ToString();
//设置只在 load 列表数据时加载颜色
if(isFormControl
!="1" && isFormControl !="true")
foreach(Dictionary < string, object > data in response.ReturnData)
//设置列名为 Mobile 的颜色为 Red
data["Mobile"】= new
H3.SmartForm.ListViewCustomcell(data["Mobile"】== null ?"--": data["Mobile"].ToString
3.自定义筛选条件
protected override void OnInit(H3.SmartForm.LoadListviewResponse
response)
H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter();
//构建过滤器
H3.Data.Filter.And andMatcher new H3.Data.Filter.And();
andMatcher.Add(new H3.Data.Filter.ItemMatcher("控件编码", H3.Data.ComparisonOperatorType.Equal,"Value"));
//添加查询条件
filter.Matcher = andMatcher;
this.Request.Filter " filter;
base.OnInit(response);
//构造 And 匹配器
4.修改列名
//修改列名称(本方法放在列表设计后端列表类内)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 == *eoooooo1")
//判断当前列的编码是否是F0000001
//将F0000001列的列名称改成供应商信息H3.SmartForm.ListviewColumn newCol - new H3.SmartForm.ListViewColumn(
"F0000001",
//列编码(对应控件编码)
"供应商信息”//列必称
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;
5.修改排序列protected override void OnInit(H3.SmartForm.LoadListViewResponse response)
base.OnInft (response);
response.SortBy =“F0000003":
//设置列表默认根据F0000003控件进行排序//response.SortDirection = H3.Data.Filter.SortDirection.Ascending;
//正序排序response.SortDirection H3.Data.Filter.SortDirection.Descending;
//倒序排序
using System;
using System.Collections.Generic;
using System.Text;
using H3;
public class D901599e66ee6404cb84224a0172df4748a4553_ListViewController :H3.SmartForm.ListViewController
public D801599e66ee6404cb84224a0172df4748a4553_ListViewController(H3.SmartForm.ListViewRequest request): base(request)
protected override void OnLoad(H3.SmartForm.LoadListViewResponse response)
base.OnLoad(response);
protected override void OnSubmit(string actionName, H3.SmartForm.ListViewPostValue postValue, H3.SmartForm.SubmitListViewResponse response)
base.OnSubmit(actionName, postValue, response);
protected override void OnLoad(H3.SmartForm.LoadListviewResponse response)
base.OnLoad(response);
protected override void OnSubmit(string actionName, H3.SmartForm.ListViewPostValue postValue, H3.SmartForm.SubmitListViewResponse response)
if(actionName =="Init")
string[] objectIds =(string[]) postValue.Data["ObjectIds"];
if(objectIds -- null ll objectIds.Length -- o)
response.Message =“请选择数据行";
return;
foreach(string item in objectIds)
H3.DataModel.BizObject biz=H3,DataModel.Biz0bject.Load(this,Request.UserContext.UserId,this.Engine,"D001599e66ee6404cb84224a0172df4748a4553",item,false);
biz["Age"]-double,Parse("@"+biz["Age"])+1;
biz.Update();
response.Message -“请选择数据行”;
return;
foreach(string item in objectids)
H3.DataModel.BizObject biz=H3.DataModel.BizObject.Load(this.Request.UserContext.UserId,this.Engine,"D801599e66ee6404cb84)
biz["Age"]=double.Parse("8"+biz["Age"])+1;
biz.Update();
base.Onsubmit(actionName, postValue, response);
foreach(Dictionary < string, object > data in response.ReturnData)
//设置列名为 Mobile 的颜色为 Redif(data["Gender"] + string-fmpty)
data["Gender"]- new H3.SmartForm.ListviewCustomcell(data["Gender"]=- null ?"--": data["Gender"].ToString(), H3.SmartForm.Color.Red);
else
data["Gender"]= new H3.SmartForm.ListviewCustomCell(data["Gender"]-- null ?"--": data["Gender"].Tostring(), H3.SmartForm.Color.Red);
//修改列名称(本方法放在列表设计后端列表类内)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 =="userName")
//判断当前列的编码是否是F0800001
//将F0000001列的列名称改成供应商信息H3.SmartForm.ListviewColumn newCol = new H3.SmartForm.ListviewColumn(
"userName",
//列编码(对应控件编码)
“供应面信息”,//列名称response.Columns[key].Visible,
response.Columns[key].Sortable,
response.Columns[key].Url,
response.Columns[key].Align,
response.Columns[key].ShowMode
//修改列名称(本方法放在列表设计后端列表类内)
// 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]);
return;
ctionName =="Init")
foreach(string item in objectids)
H3.DataModel.BizObject biz = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId,this.Engine,"D001599e66ee6404cb84224a0172df4748a4553", item, false);
biz["Age"]= double.Parse("8"+ biz["Age"])+ 1;
biz.Update();
ctionName --"Copy")
foreach(string item in objectids)
H3.DataModel.BizObject biz = H3.DataModel.Biz0bject.Load(this.Request.UserContext.UserId,this.Engine,"D801599e66ee6404cb84224a0172df4748a4553", item, false);
H3.DataModel.Biz0bject newBiz=new H3.DataModel.BizObject(this.Engine,this.Engine.Biz0bjectManager.GetPublished5chema("D001599e66ee6404cb8422480172df4748a4553"),this。
newBiz["userName"]=biz["userName"];
newBiz["Age"]-biz["Age"];
newBiz["Gender"]=biz["Gender"];
newBiz.Status-H3.DataModel.BizObjectStatus.Effective;
newBiz.Create();
using System;
using System.Collections.Generic;
using System.Text;
using H3;
public class Do01599d2278a8349a0406aa2597573090563bb_ListviewController :H3.SmartForm.ListviewController
public D601599d2278a8349a0486aa2597573090563bb_ListViewController(H3.5martForm.ListViewRequest request):base(request)
protected override void OnLoad(H3.SmartForm.LoadListviewResponse response)
string upSql="update I D601599d2278a8349a6486aa2597573090563bb set sumMoney=prodPrice*prodNumb";
this.Engine.Query.yueryTable(upSql,null);
base.OnLoad(response);
protected override void OnSubmit(string actionName, H3.SmartForm.ListViewPostValue postValue, H3.SmartForm.SubmitListViewResponse response)
base.OnSubmit(actionName, postValue, response);