Skip to main content

Add-Column

Command Description

Add a column of data to the datatable

Command Prototype

Datatable.AddColumn(dtTable,column,iIndex,objDefaultValue)

Parameter Description

ParameterRequiredTypeDefaultDescription
dtTableTrueexpressionobjDatatableThe data table to be filtered
columnTruestring""Name of the increased data column
iIndexTrueexpressionnullThe position of the column added to the datatable, if it is null, then add it to the last
objDefaultValueTruestring""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
*/