createColumn method

SimpleTableColumn createColumn(
  1. String headerCaption,
  2. int width, {
  3. bool sortable = false,
  4. String vAlign = 'left',
  5. int precision = 0,
})

Implementation

SimpleTableColumn createColumn(String headerCaption, int width,
    {bool sortable = false, String vAlign = 'left', int precision = 0}) {
  final column = SimpleTableColumn()
    .._width = width
    ..caption = headerCaption
    ..sortable = sortable
    ..precision = precision
    ..vAlign = vAlign;
  columns.add(column);
  final headerCell = headersRow.createColumnHeaderCell(column);
  column.headerCell = headerCell;
  if (sortable) {
    headerCell.nodeRoot.onClick.listen((e) {
      var sortSymbol = '';
      if (headerCell.text == column.caption) {
        sortSymbol = '▲';
      } else if (headerCell.text.endsWith('▲')) {
        sortSymbol = '▼';
      }
      for (final col in columns) {
        col.headerCell.text = col.caption;
      }
      headerCell.text = '${column.caption} $sortSymbol'.trim();
      sortData(columns.indexOf(column), sortSymbol);
    });
  }
  return column;
}