Re: Displaying column totals for a DefaultDataTable

2009-09-16 Thread saahuja

Ok, here is my code for the TotalsToolbar that I am adding as a
BottomTooolbar to my table.

public class TotalsToolbar extends AbstractToolbar
{

public TotalsToolbar(final DataTable table, final IDataProvider
dataProvider)
{
super(table);

RepeatingView totals = new RepeatingView(totals);
add(totals);

final IColumn[] columns = table.getColumns();
for (int i = 0; i  columns.length; i++)
{
final IColumn column = columns[i];

WebMarkupContainer item = new
WebMarkupContainer(totals.newChildId());
totals.add(item);

WebMarkupContainer total = new WebMarkupContainer(total);

item.add(total);
item.setRenderBodyOnly(true);
if (i == 0)
total.add(new Label(value, Grand Total));
else
total.add(new Label(value, $0.00));

}
}

As you can see I am passing in a dataProvider into the constructor, but I do
not know how to use it. How do I replace the hardcoded $0.00 value (look
towards the end of the code) with a value coming from the dataProvider?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Displaying-column-totals-for-a-DefaultDataTable-tp25402522p25475784.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Displaying column totals for a DefaultDataTable

2009-09-16 Thread saahuja

Sorry, never mind my previous post. I figured it out. I just need to use the
iterator() on the dataProvider to get the values.
Thanks.
-- 
View this message in context: 
http://www.nabble.com/Displaying-column-totals-for-a-DefaultDataTable-tp25402522p25477218.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Displaying column totals for a DefaultDataTable

2009-09-11 Thread Sadhna Ahuja
Hello,

 

I have a DefaultDataTable with several amount colums. I need to display
a Totals row at the bottom of the table to show the column totals.

 

I have searched the forum, and only found suggestions to use
addBottomToolbar.

 

However, I don't know how to do this? Looking at Wicket's HeaderToolbar,
I see that I would need to pass the DataTable and the
SortableDataProvider to my TotalsToolbar.

 

But, how would the toolbar get the data to display?

 

What would the html markup for this toolbar be like?

 

Would greatly appreciate if someone could please provide some sample
code.

 

Thanks in advance.

 

 

 

 



Re: Displaying column totals for a DefaultDataTable

2009-09-11 Thread Michael Mosmann
Hi,

 I have a DefaultDataTable with several amount colums. I need to display
 a Totals row at the bottom of the table to show the column totals.

 I have searched the forum, and only found suggestions to use
 addBottomToolbar.

correct..

 However, I don't know how to do this? Looking at Wicket's HeaderToolbar,
 I see that I would need to pass the DataTable and the
 SortableDataProvider to my TotalsToolbar.

yes.. correct.

 But, how would the toolbar get the data to display?

public class TotalCounter extends AbstractToolbar
{

public TotalCounter(final DataTable dataTable)
{

IModelInteger model=new LoadabledDetachedModelInteger()
{
  public Integer load()
  {
return dataTable.size()
  }
}

WebMarkupContainer span = new WebMarkupContainer(span);
add(span);
span.add(new AttributeModifier(colspan, true, new ModelString(
String.valueOf(table.getColumns().length;

span.add(new Label(count,model));
}

 What would the html markup for this toolbar be like?

wicket:panel
  tr class=navigation
td wicket:id=span
  span wicket:id=counter/counter
/td
  /tr
/wicket:panel
 

 Would greatly appreciate if someone could please provide some sample
 code.

maybe this will work out of the box, but not sure.. 
(have a look into the wicket code.. .. it will help a lot)

mm:)


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Displaying column totals for a DefaultDataTable

2009-09-11 Thread saahuja

Thanks for your reply, Michael.

Your code does work to display the number of columns in the dataTable, after
I changed dataTable.size() to dataTable.getRowCount(). It did help me in
getting started with writing my own toolbar.

However, my table has several amount columns and I want to display the sum
of the amounts in each column at the bottom of that column.

How should I do that? I am also passing in a SortableDataProvider into the
constructor of my Toolbar.

Thanks.


-- 
View this message in context: 
http://www.nabble.com/Displaying-column-totals-for-a-DefaultDataTable-tp25402522p25406289.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Displaying column totals for a DefaultDataTable

2009-09-11 Thread Michael Mosmann
 Your code does work to display the number of columns in the dataTable, after
 I changed dataTable.size() to dataTable.getRowCount(). It did help me in
 getting started with writing my own toolbar.

Ok.. id did it in this email client, which has very poor development
support:) but it was good enough to show you the way:) ..

 However, my table has several amount columns and I want to display the sum
 of the amounts in each column at the bottom of that column.

for the rows displayed or all rows in this columns?
i think, you mean the second.. so it is not trivial, because you should
not iterate over all entries to build up this numbers..

maybe this is a valid solution:

you have somewhere a function which gives you the list of items.. maybe
ListMyEntity MyEntity.getList(offset,count).. you need a function
which returns on Instance of MyEntity filled whith sum for each property
(select sum(prop1),sum(prop2)... - MyEntity.setProp1(sum1) ..)

than take a DataGridView .. see DataTable.java to get a picture of what
you need.. so you can reuse the List of IColumn.

if you have any further questions.. send some code.

mm:)

there are many good wicket books available .. do you have one? 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org