Search in sources :

Example 6 with TableDataModel

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

the class WDataTableRenderer_Test method testDoPaintSortableSortModeDynamic.

@Test
public void testDoPaintSortableSortModeDynamic() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    TableDataModel tableModel = createTableModelSortable();
    component.setDataModel(tableModel);
    component.setVisible(true);
    // sortMode dynamic
    component.setSortMode(SortMode.DYNAMIC);
    assertXpathEvaluatesTo("dynamic", "//ui:table/ui:sort/@mode", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[1]/@sortable", component);
    assertXpathNotExists("//ui:table/ui:thead/ui:th[2]/@sortable", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[3]/@sortable", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 7 with TableDataModel

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

the class WDataTableRenderer_Test method testDoPaintWithColAlignment.

@Test
public void testDoPaintWithColAlignment() throws IOException, SAXException, XpathException {
    WDataTable table = new WDataTable();
    table.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    table.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    table.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    table.getColumn(0).setAlign(WTableColumn.Alignment.LEFT);
    table.getColumn(1).setAlign(WTableColumn.Alignment.CENTER);
    table.getColumn(2).setAlign(WTableColumn.Alignment.RIGHT);
    TableDataModel tableModel = createTableModel();
    table.setDataModel(tableModel);
    assertXpathNotExists("//ui:table/ui:thead/ui:th[1]/@align", table);
    assertXpathEvaluatesTo("center", "//ui:table/ui:thead/ui:th[2]/@align", table);
    assertXpathEvaluatesTo("right", "//ui:table/ui:thead/ui:th[3]/@align", table);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 8 with TableDataModel

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

the class WDataTableRenderer_Test method testDoPaintExpandModeLazy.

@Test
public void testDoPaintExpandModeLazy() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    TableDataModel tableModel = createTableModel();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.setExpandMode(ExpandMode.LAZY);
    assertXpathEvaluatesTo("lazy", "//ui:table/ui:rowexpansion/@mode", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 9 with TableDataModel

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

the class WDataTableRenderer_Test method testDoPaintSortableSortModeDynamicClientSettings.

@Test
public void testDoPaintSortableSortModeDynamicClientSettings() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    // sortable data model
    TableDataModel tableDataModel = createTableModelSortable();
    component.setDataModel(tableDataModel);
    component.setVisible(true);
    component.setSortMode(SortMode.DYNAMIC);
    setActiveContext(createUIContext());
    MockRequest request = new MockRequest();
    String colIndexStr = "0";
    request.setParameter(component.getId() + "-h", "x");
    request.setParameter(component.getId() + ".sort", colIndexStr);
    request.setParameter(component.getId() + ".sortDesc", TRUE);
    component.handleRequest(request);
    assertXpathEvaluatesTo("dynamic", "//ui:table/ui:sort/@mode", component);
    assertXpathEvaluatesTo(colIndexStr, "//ui:table/ui:sort/@col", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:sort/@descending", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[1]/@sortable", component);
    assertXpathNotExists("//ui:table/ui:thead/ui:th[2]/@sortable", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[3]/@sortable", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) MockRequest(com.github.bordertech.wcomponents.util.mock.MockRequest) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 10 with TableDataModel

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

the class WDataTableRenderer_Test method testDoPaintSelectModeSingle.

@Test
public void testDoPaintSelectModeSingle() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    TableDataModel tableModel = createTableModel();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.setSelectMode(WDataTable.SelectMode.SINGLE);
    assertXpathExists("//ui:table/ui:rowselection", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

TableDataModel (com.github.bordertech.wcomponents.TableDataModel)28 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)24 WDataTable (com.github.bordertech.wcomponents.WDataTable)23 SimpleTableDataModel (com.github.bordertech.wcomponents.SimpleTableDataModel)22 Test (org.junit.Test)22 WTextField (com.github.bordertech.wcomponents.WTextField)21 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)6 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)4 WButton (com.github.bordertech.wcomponents.WButton)4 ActionConstraint (com.github.bordertech.wcomponents.WDataTable.ActionConstraint)4 UIContext (com.github.bordertech.wcomponents.UIContext)3 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)3 WComponent (com.github.bordertech.wcomponents.WComponent)2 WRepeater (com.github.bordertech.wcomponents.WRepeater)2 TreeNode (com.github.bordertech.wcomponents.util.TreeNode)2 AbstractTableDataModel (com.github.bordertech.wcomponents.AbstractTableDataModel)1 AbstractTreeTableDataModel (com.github.bordertech.wcomponents.AbstractTreeTableDataModel)1 WDataTableRowRenderer (com.github.bordertech.wcomponents.WDataTableRowRenderer)1 SubUIContext (com.github.bordertech.wcomponents.WRepeater.SubUIContext)1 WText (com.github.bordertech.wcomponents.WText)1