calcMaxWidthByContent();
The calcMaxWidthByContent method calculates maximum column length relative to the column contents.
The method use is relevant if the DataGrid.EnableAutoSize property is set to True.
To execute the example, the HTML page must contain the DataGrid component named grid (see Example of Creating the DataGrid Component). Enable autocalculation of table element size and calculate maximum width of the first column relative to the column contents:
// Set autocalculation of table element size grid.setEnableAutoSize(True); // Calculate maximum width of the first column console.log("Maximum width of the first column: " + grid.getMeasures().getColumns()[0].calcMaxWidthByContent());
As a result, the console displays maximum width value of the first column relative to the contents:
Maximum width of the first column: 17
Get width and height of the second column calculated relative to the contents:
// Get height of the second column calculated relative to the contents console.log("Second column height: " + grid.getMeasures().getColumns()[1].getHeightByContent()); // Get second column width calculated relative to the contents console.log("Second column width: " + grid.getMeasures().getColumns()[1].getWidthByContent());
The console displays height and width calculated relative to the contents:
Second column height: 14
Second column width: 40
See also: