Search in sources :

Example 1 with SimpleTableDataModel

use of com.github.bordertech.wcomponents.SimpleTableDataModel in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method createTableModelSortable.

/**
 * @return a test TableDataModel for sroting
 */
private TableDataModel createTableModelSortable() {
    String[][] data = new String[][] { new String[] { "Joe2", "Bloggs2", "01/02/1971" }, new String[] { "Jane2", "Bloggs2", "04/05/1972" }, new String[] { "Abel2", "Bloggs2", "31/12/2000" } };
    SimpleTableDataModel model = new SimpleTableDataModel(data);
    // col 1 and 3 sortable
    model.setComparator(0, new StringComparator());
    // model.setComparator(1, new StringComparator());
    model.setComparator(2, new StringComparator());
    // sort on column1, descending - tableDataModel only
    model.sort(0, false);
    model.setEditable(true);
    return model;
}
Also used : SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel)

Example 2 with SimpleTableDataModel

use of com.github.bordertech.wcomponents.SimpleTableDataModel in project wcomponents by BorderTech.

the class SelectableDataTableExample method createTable.

/**
 * Creates and configures the table to be used by the example. The table is configured with global rather than user
 * data. Although this is not a realistic scenario, it will suffice for this example.
 *
 * @return a new configured table.
 */
private WDataTable createTable() {
    WDataTable table = new WDataTable();
    table.addColumn(new WTableColumn("First name", new WText()));
    table.addColumn(new WTableColumn("Last name", new WText()));
    table.addColumn(new WTableColumn("DOB", new WText()));
    String[][] data = new String[][] { new String[] { "Joe", "Bloggs", "01/02/1973" }, new String[] { "Jane", "Bloggs", "04/05/1976" }, new String[] { "Kid", "Bloggs", "31/12/1999" } };
    table.setDataModel(new SimpleTableDataModel(data));
    return table;
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WText(com.github.bordertech.wcomponents.WText) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel)

Example 3 with SimpleTableDataModel

use of com.github.bordertech.wcomponents.SimpleTableDataModel in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method createTableModel.

/**
 * @return a test TableDataModel.
 */
private TableDataModel createTableModel() {
    String[][] data = new String[][] { new String[] { "Joe", "Bloggs", "01/02/1973" }, new String[] { "Jane", "Bloggs", "04/05/1976" }, new String[] { "Kid", "Bloggs", "31/12/1999" } };
    SimpleTableDataModel model = new SimpleTableDataModel(data);
    model.setEditable(true);
    return model;
}
Also used : SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel)

Aggregations

SimpleTableDataModel (com.github.bordertech.wcomponents.SimpleTableDataModel)3 WDataTable (com.github.bordertech.wcomponents.WDataTable)1 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)1 WText (com.github.bordertech.wcomponents.WText)1