Add-Column
Command Description
Add a column of data to the datatable
Command Prototype
Datatable.AddColumn(dtTable,column,iIndex,objDefaultValue)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
dtTable | True | expression | objDatatable | The data table to be filtered |
column | True | string | "" | Name of the increased data column |
iIndex | True | expression | null | The position of the column added to the datatable, if it is null, then add it to the last |
objDefaultValue | True | string | "" | Values to be filled in the column, can be an array or a single value |
Demo
aryData = [["a", 1], ["b", 2], ["c", 3], ["d", 1]]
aryColumns = ["letter", "number"]
objDatatable = Datatable.BuildDataTable(aryData,aryColumns)
Datatable.AddColumn(objDatatable,"other",null,"123")
TracePrint(objDatatable)
/*
letter number other
0 a 1 123
1 b 2 123
2 c 3 123
3 d 1 123
*/