Static buildStatic method that helps to build a table model object. It takes in tabular data and options and constructs a suitable model for rendering as a table. This method is capable of handling both 'Flat' and 'Tree' data structures.
An array of the data rows. The type of these rows could be anything which is defined by the generic type parameter T.
An array of objects that define the columns of the table. Each object represents one column.
A configuration object that allows you to customize how the table is displayed and behaves. This is optional, and if not provided it defaults to a new instance of TableOptions.
Optional parameter that specifies the number of columns that should remain fixed from the left side of the table while scrolling horizontally. It defaults to 0 if not provided.
Optional parameter that specifies the number of columns that should remain fixed from the right side of the table while scrolling horizontally. It defaults to 0 if not provided.
A TableModelIf object which can be used to render the table. The TableModelIf defines the structure of the table and contains all its data and state.
T - The type of the data in the rows.
Here is an example of using this static method to build a table model:
const tableModel = TableFactory.buildByTypedRows<User>(users, [{ property: 'name', headerLabel: 'Name' }, { property: 'email', headerLabel: 'Email' }]);
This will build a table with two columns 'Name' and 'Email', each row representing a 'User' object from the 'users' array.
Warning: This function assumes that the first columnDef provided represents a checkbox column if the property of the first columnDef is "CheckboxColumn". If the first column is not a checkbox column, ensure that the first columnDef does not have "CheckboxColumn" as its property.
Static buildConstructs a table model (an instance of TableModelIf) by using provided parameters.
The generic parameter that represents the datatype of rows.
The parameter object.
The definition of columns that are to be used in the table model.
Optional fixedOptional parameter that specifies the count of fixed (non-scrollable) columns from the left. Defaults to 0.
Optional fixedOptional parameter that specifies the count of fixed (non-scrollable) columns from the right. Defaults to 0.
The rows data to be used in the table model.
Optional tableOptional table options that may override default table settings. Defaults to new TableOptions().
The newly constructed table model.
Static createThis public static factory method creates a TableModel instance using the provided parameters.
Each parameter has a default value allowing for great flexibility in creating table models.
The main parameters are the AreaModel instances for different table sections:
This parameter of type AreaModelIf represents the header area of the table.
The default value is a new instance of AreaModelHidden, indicating an invisible header.
This parameter of type AreaModelIf represents the body area of the table and is required.
It needs to be passed as it contains all the row data that will be displayed in the table.
This AreaModelIf type parameter represents the footer area of the table.
Similar to headerAreaModel, the default value is a new instance of AreaModelHidden, indicating an invisible footer.
Also, the method receives parameters for fixed columns, row checkbox visibility, default row heights, column definitions, column sizes, overriding column width, and column count:
This value indicates the number of fixed columns on the left side of the table.
The default value is 0, no fixed column by default.
This value indicates the number of fixed columns on the right side of the table.
Similarly to fixedLeftColumnCount, its default value is 0.
This is a boolean that determines whether a checkbox will be visible for each row.
The default value is false, indicating that checkboxes will not be displayed unless otherwise specified.
This object of type DefaultRowHeightsIf allows setting of the default row heights for the table sections.
By default, it creates a new DefaultRowHeights instance with values of 34 for header, body and footer.
Here, an array of ColumnDefIf[] needs to be passed to specify the column definitions.
This is an array of number[] providing custom column sizes.
If not defined, an empty array [] is used.
This number sets a uniform width for all columns, overriding individual column sizes.
Default value is -1, indicating that this feature is disabled by default.
This is the total column count.
A new instance of TableModel is created using the provided parameters.
If a parameter isn't provided, the default value is used.
Static createTableFactory.createByAreaModelsParam is a static method in the TableFactory class that creates a table model by area models and other optional parameters.
This method allows more flexibility and control over table building by providing the option to decide the visibility and nature of the header, body, footer, columns, and rows in the table.
Optional columnOptional columnOptional columnOptional defaultOptional fixedOptional fixedOptional footerOptional headerOptional overridingOptional rowa new instance of TableModelIf created by the createByAreaModels method of TableFactory using the provided parameters.
Note: The area models (headerAreaModel, bodyAreaModel, footerAreaModel) should be initialized before being passed to this method. If not initialized, they might need to call their init method to ensure proper functioning.
const tableModel = TableFactory.createByAreaModelsParam({
headerAreaModel: myHeaderModel,
bodyAreaModel: myBodyModel,
footerAreaModel: myFooterModel,
fixedLeftColumnCount: 2,
fixedRightColumnCount: 1,
rowCheckboxVisible: true,
defaultRowHeights: myDefaultHeights,
columnDefs: myColumnDefs,
columnSizes: [100, 100, 200],
overridingColumnWidth: 150,
columnCount: 3
});
Static createClass method createByObjectArray of the TableFactory class.
This public, static method is intended to create a table model by an array of objects. This method is particularly useful when you are aiming to build a table from a set of data rows, header and footer information. The table can include both fixed and flexible columns and optional checkboxes for each row. The table layout can further be customized using the default row heights, column definitions, and column sizes parameters.
It returns an instance of TableModel with all the provided/processed parameters.
Note: You need to import the AreaModelArrayOfArrays and AreaModelHidden classes from the respective package/module before using this method.
Simpler with named parameters: createTableModel.
T - The generic type parameter for data rows.
const rows = [{ field1: "data11", field2: "data12" }, { field1: "data21", field2: "data22" }];
const columnDefs: ColumnDefIf[] = [new ColumnDef("field1", "Field 1"), new ColumnDef("field2", "Field 2")];
const tableModel = TableFactory.createByObjectArray(rows, undefined, undefined, 0, 0, false, new DefaultRowHeights(), columnDefs);
Static createThe createByObjectArrayParam static method is used to create a TableFactory object with the data contained in the param object.
This method would call the createByObjectArray static method, which actually constructs the TableModel object with the provided data.
Defines the type of the items contained in the rows.
Method parameter as an object that carries several properties described below:
Optional columnOptional array of column definitions, each is an object conforming to ColumnDefIf interface.
Optional columnOptional array of numbers providing the specific sizes for columns.
Optional defaultOptional object defining default heights of rows in different sections of the table. Defaults to new DefaultRowHeights().
Optional fixedOptional number detailing how many of the beginning columns are sticky to the left.
Optional fixedOptional number detailing how many of the ending columns are sticky to the right.
Optional footer?: string[][]Optional array of arrays with the table footer data.
Optional header?: string[][]Optional array of arrays with the table header data.
Optional rowOptional flag that indicates whether checkboxes are visible in the rows.
Array of table row data that can be of any type.
A TableFactory object created by the createByObjectArray method.
let param = {
rows: [{name: 'John', age: 30}, {name: 'Doe', age: 40}],
header: [['Name', 'Age']],
footer: [['Avg', '35']],
fixedLeftColumnCount: 1,
fixedRightColumnCount: 0,
rowCheckboxVisible: true,
defaultRowHeights: new DefaultRowHeights(40, 50, 40),
columnDefs: [
new ColumnDef('name', 'Name', px100),
new ColumnDef('age', 'Age', px50)
],
columnSizes: [100, 50]
};
const tableModel = TableFactory.createByObjectArrayParam(param);
Static createCreates a table model from any subset of CreateTableModelPara. Missing parts are derived (see CreateTableModelPara).
rows, column definitions, area models, fixed columns, options …
the table model for new TableScope(host, tableModel, …) or the tableModel input of a framework wrapper
const tableModel = TableFactory.createTableModel({
rows: orders,
columnDefs,
fixedLeftColumnCount: 1,
footerAreaModel: new OrderTotalsFooterModel(() => tableModel.getBodyModel())
});
Creates table models from data – the usual way to start a table.
Trees: build the rows with TreeFactory.buildTreeRows first, then pass them as
rows.Example
See
Training: Array<T> → TableModel, Array of arrays