Catersa
Catersa

Reputation: 125

List<String> custom gwt data display

The environment that i am using its GAE+GWT+GXT-GWT

I am doing a sql query and returning the results into a List.

The structure of the List is like :

::12::AA254712::34::5::7::ZTA
::13::AA245789::3::7::8::XMA
::15::AA254712::4::7::5::ZTA

As per my client needs, i was creating a HtmlLayoutContainer (GXT-GWT), splitting each data row, assigning those values to widgets (textbox and label), and then feeding those through the add method to the HtmlLayoutContainer previously defined.

Thus the printed data was following this schema:

ORDER    IDENTIFIER    QUANTITY    QUALITY    SIZE    REFERENCE
===============================================================
12       AA254712      34          5          7       ZTA
13       AA245789      3           7          8       XMA
15       AA254712      4           7          5       ZTA

But now my client has sent us a new requirement, and i have been hitting a wall for two days to achieve what my client needs.

The new requirement states that, if two or more products share the same identifier, they should be printed together and not all the values but a few of them, like this:

ORDER    IDENTIFIER    QUANTITY    QUALITY    SIZE    REFERENCE
===============================================================
12       AA254712      34          5          7       ZTA
15                     4           7          5       

13       AA245789      3           7          8       XMA

I have used a group by sql sentence by Identifier, to group the results that share the same identifier, but what i havent realized yet how to do it, its to trim the results and how to add those to the container. I thought of using StringTokenizer, but its not allowed by GWT.

Can someone lend me a hand?

Thank you,

The code :

Basically is something like this (among some other stuff that its not needed):

static VerticalLayoutContainer r = new VerticalLayoutContainer();

public static FramedPanel drawData(List<String> resultListRefAgent) {

HtmlLayoutContainer con;

Collections.sort(resultListRefAgent);

for (int ini = 0; ini<=resultListRefAgent.size();ini++) {

con = new HtmlLayoutContainer(new getReferenceData());

(Various Widgets declarations (Label, TextBox)).

JsArrayString temp = null;

(String declarations)

if (resultListaRefAgente.size()>ini) { temp = split(resultListaRefAgente.get(ini), "::");

(Assign those temp.get(index) to the previously defined string declarations).

(.setText to each previously defined widget with the assigned values).

con.add(widgetName, new HtmlData(".widgetName")); <-- .widgetName is defined as well into the table layout defined in getReferenceData.

r.add(con);
}

The split method has the following code:

public static final native JsArrayString split(String string, String separator) /*-{
return string.split(separator);
}-*/;

Upvotes: 0

Views: 461

Answers (2)

El Hoss
El Hoss

Reputation: 3832

You are using GXT. Have you tried to work with a Grouping Grid?

Grouping Grid

Upvotes: 0

StephaneM
StephaneM

Reputation: 4899

In your SQL, just order your data using order by then when you add to the HtmlLayoutContainer keep track of the idenfier of the prvious row and put empty identifier and reference if they are the same.

Upvotes: 1

Related Questions