Tritium cloud learning 2 - sub table

Posted by zavin on Sat, 23 Oct 2021 03:16:24 +0200

Common methods of sub table front end:

methodeffect
AddRowAdd sub table row data
UpdataRowUpdate sub table row data
ClearRowsClear sub table rows
GetCellManagerGets the control of the child table
this.D000001AccountList.ClearRows();//Delete the sub table row, and d00001accountlist is the sub table code

//Add child table row
var subObjectId = $.IGuid();  //Create row ID
this.D000001AccountList.AddRow( subObjectId, {
        "D000001AccountList.F0000001": "Assignment 1",
        "D000001AccountList.F0000002": "Assignment 2",
        "D000001AccountList.F0000003": "Assignment 3"
 })

//Update (modify) sub table data
var currentRowId =this.F67c89495df154ab69ede62c1b61a0658.GetValue()[x].
ObjectId; //Get the sub table ID in row x, where F67c89495df154ab69ede62c1b61a0658 is the sub table ID this.F67c89495df154ab69ede62c1b61a0658.updaterow (currentrowid{
             "F67c89495df154ab69ede62c1b61a0658.jyjg": "assignment",
             "F67c89495df154ab69ede62c1b61a0658.dqgys": "assignment",
             "F67c89495df154ab69ede62c1b61a0658.cpmc": "assignment"
});
//Loop through the sub table to update the data
var zibiao =this.F67c89495df154ab69ede62c1b61a0658.GetValue();
for(var i=0;i<zibiao.length;i++)
{
	var currentRow=ziaobiao.[i].ObjectId;
	this. F67c89495df154ab69ede62c1b61a0658.UpdataRow{
             "F67c89495df154ab69ede62c1b61a0658.jyjg": "assignment",
             });

}


In fact, the controls of the child table and the main table are bizobjects. The only difference is that the controls of the child table will have a parent table ID: parentobjectid

When binding the change event, you cannot bind a row of data in the sub table, but bind the sub table object
When binding the main table:

this.F0000001.BindChange('key',function(){
	alert)("Main table binding event");
})

When the child table is bound

//A child table binding event can only bind a child table object, not a specific control in the child table. To bind a control to an event, you need to add a callback parameter res in function to judge whether a specific data triggers an event,
var parent=this;//Because BindChange is a callback function, the internal use of this is the this of function, not the this of the sub table. Therefore, save the this of the sub table first
this.F67c89495df154ab69ede62c1b61a0658.BindChange('key',function(res){
	if(res[0].DataField=="F67c89495df154ab69ede62c1b61a0658.F000002"){//DataField is the object that gets the control
		alert("Child table control binding event);
		ver objectid=res[0].ObjectId;//Gets the object ID of the current row data
		//Parent.f67c89495df154ab69ede62c1b61a0658. GetValue() [0]. Objectid; because res is the sub table object returned by the BIndChange callback function, row data can be obtained directly. Otherwise, row data can be obtained by GetValue
		var cellObj = parent.F67c89495df154ab69ede62c1b61a0658.GetCellManager(   cellObj , "F67c89495df154ab69ede62c1b61a0658.F0000001" );//Get child table control
		cellObj.SetReadonly(true);//After obtaining the control, you can perform various operations on the control
	}
	//At this time, the overall implementation of the code is to alert when the data of the sub table control F0000002 changes, and the sub table control F0000001 changes to read-only.
});

practice

Verify data during delivery

You can directly set the verification conditions in form settings - form verification. When the verification fails, an error message will be prompted,

Repeated inspection of sub table data

The duplicate check of the main table only needs to be checked in the control property that duplicate entry is not allowed, but the control property of the sub table does not have this option, so it can only be implemented in code

Using system.data;
//Add the following code to OnSubmit of the backend code
H3.DataModel.BizObject[] child =(H3.DataModel.BizObject[]) this.Request.BizObject["F67c89495df154ab69ede62c1b61a0658"];
foreach(H3.DataModel.BizObject item in child){
	string repStr = string.Formet("select * from I_F67c89495df154ab69ede62c1b61a0658 where F0000001='{0}' ",item["F0000001"]+string.Empty)
	DataTable repDt=this.Engine.Query.QueryTable(repStr,null);
	if(repDt !=null&&repDt,Rows,Count>0){
		response.Infos.Add("Repeated submission of sub table data");
	}
}

Use business planning to add data to the sub table of a goal

In a task publishing, the task log is added each time.
Create a form: task Publishing
Main table text: task name, task publisher
Sub table text: log submission time, submitter,
Create a form: log submission
Main table text: log content,
Other contents of the main table: Creator, creation time (these two are existing controls),
Associated form: associated form "task publishing"
That is, "task publishing" publishes a task, and then "log submission log", which will add the log information to the sub table of task publishing

Here, only the operation mode of the window interface is introduced

Switch to the advanced mode in form settings - business rules - new business rules - select when the form becomes effective——
INSERT (select sub table published by task, main table ID of sub table, associated form, sub table object 1, main table object 1, sub table object 2, main table object 2...)
At this time, the sub table published by the task is the target form, and the form submitted by the log is the current form.