0

I need to create a quarterly expense report and I am confused what layout and widgets would be useful here

    Quarter 1   Quarter 2   Quarter 3

Expense 1
Expense 2
Expense 3

I understand Celltable and DataGrids, but not sure If I can have data mappings of objects in the format as above. Mainly because these tables work with objects at a row level.

I have an object with data of the entire column instead. Any ideas/ suggestions here ?

V Kumar
  • 25
  • 5

1 Answers1

0

You have many options to choose from. The most obvious one is a FlexTable, but you can also simply put three floating FlowPanels next to each other.

With GWT you should use HTML for your layouts as much as possible unless you need some specific functionality from a widget.

EDIT:

Alternatively, you can use a DataGrid with a single row, where each cell is a custom cell that renders your object.

Finally, you can use DataGrid as a regular DataGrid - just modify the logic of what is displayed in each cell. For example, a cell can render like this:

    final TextColumn<Integer> quarterColumn = new TextColumn<Integer>() {
        @Override
        public String getValue(Integer row) {
            int column = myDataGrid.getColumnIndex(quarterColumn);
            QuarterObject object = quarterObjects(column - 1);
            return object.getExpense(row - 1);
        }
    };

Then you simply populate your DataProvider with an array of Integers from 1 to the number of records in your QuarterObject.

Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
  • Andrei - My objects contains the data for an entire column. Example I have an expense object which contain value for expense1, expense2, expense 3 and so on. And I have multiple expense objects, one for each quarter. How would Flextable or flowpanel help in rendering these objects per column? I also need to add header columns on top and left. – V Kumar Mar 12 '15 at 07:48
  • There is no ready-made widget to do what you want. So you have to build your own. It will consist of the standard building blocks - panels, labels, etc., and your own logic how to populate it. You can look at the source code for a DataGrid as an example of such a widget. – Andrei Volgin Mar 12 '15 at 08:09
  • I used a combination of HorizontalPanel with FlexTable as suggested by you. And I think I will be able to accomplish my needs using this. Thanks for your suggestions and help. – V Kumar Mar 12 '15 at 10:20
  • You can then accept the answer. Welcome to the community! – Andrei Volgin Mar 12 '15 at 10:34