Paul-

Thanks again for all your help. As an FYI, your image didn't come
through. Not sure if you forgot to attach it, or if they aren't
allowed on the mailing list.

I should have mentioned from the start that I was looking to keep this
generic/reusable. I have an implementation working and it doesn't feel
too clunky, so I think I'm on the right track. You can find all of the
code here https://github.com/wspeirs/wicket-details-table/ and the
relevant bits here
https://github.com/wspeirs/wicket-details-table/tree/master/table-test/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data

In the end I extended the DataTable so that I could modify the html
source and add a details row for each repeated row. I created a new
type of column (well two actually) AbstractDetailsColumn which extends
IColumn. This column takes care of implementing the populateItem
method so long as you provide implementations for getDetailsComponent
and getCellComponent. These two methods do exactly what you think they
should/would do. Using an implementation of the AbstractDetailsColumn
you will get a details column which is displayed default for each row
in the table. If you'd rather that column toggle its visibility (my
original request), then you can use the TogglingDetailsColumn class
which adds in the few extra calls to setup an AJAX call to set the
visibility. The implementer of getCellComponent will have to setup the
toggling in whatever AjaxComponent they pick.

Could those of you on the mailing list with more internal development
experience provide some feedback? This is my first project extending
Wicket in any serious way, and I'd eventually like to file a JIRA
ticket and get this into the next release of wicket-extensions if
they'll take it.

Thanks in advance, and I hope this helps others in the future!

Bill-

On Wed, Oct 10, 2012 at 11:54 AM, Paul Bors <p...@bors.ws> wrote:
> See attached "Add a row to a DataTable.png" for a before/after screen shoots
> of how our table of selected items looks like after a row has been added to
> the top of it and refreshed.
>
> ~ Thank you,
>   Paul Bors
>
> -----Original Message-----
> From: Paul Bors [mailto:p...@bors.ws]
> Sent: Wednesday, October 10, 2012 11:33 AM
> To: users@wicket.apache.org
> Subject: RE: Dynamically Toggling a Details Row in a DataTable
>
> Add a boolean flag to your POJO (domain model object type).
> When you click the details link, set it to true and refresh the table.
>
> When the table refreshes it will hit your DataProvider which will be in
> charge of adding the new POJO with the description at the right location in
> the list (after the one elements that have been marked with true) for the
> current page. Then when the table renders, you would grab a hold of the
> cell's TD element and set its "colspan" attribute to the number of the
> columns and render the HTML you want in it (see how toolbars to the same
> thing).
>
> As an idea, you might need a second flag to represent the type of the row
> (simplified or detailed) or use inheritance and store the type flag at the
> parent class and your collection should hold children as returned via a
> getRowContent() method.
>
> ~ Thank you,
>   Paul Bors
>
> -----Original Message-----
> From: William Speirs [mailto:wspe...@apache.org]
> Sent: Wednesday, October 10, 2012 10:25 AM
> To: users@wicket.apache.org
> Subject: Re: Dynamically Toggling a Details Row in a DataTable
>
> Paul-
>
> I've modified my DataProvider to provide double the rows. I've also extended
> DataTable to set display: hidden on the details row and also to expand the
> first column to all of the columns.
>
> The main issue I'm having now is linking the button (in say the first
> column) to something which can change the attributes of the cell. I guess my
> main question is, what should control the stat of if a details row is hidden
> or not?
>
> Bill-
>
> On Wed, Oct 10, 2012 at 2:20 AM, Martin Grigorov
> <mgrigo...@apache.org>wrote:
>
>> Hi,
>>
>> Check
>> http://wicketinaction.com/2008/10/repainting-only-newly-created-repeat
>> er-items-via-ajax/ This may give you an idea how to add/remove
>> additional rows with Ajax.
>>
>> On Tue, Oct 9, 2012 at 11:21 PM, Bill Speirs <bill.spe...@gmail.com>
>> wrote:
>> > Paul-
>> >
>> > Thanks for the response... yea, we'd like to see another row below
>> > the current one, and in an single column. This way we can put
>> > whatever component/panel we'd like in that new row. Any suggestions
>> > on where to
>> get
>> > started? I feel as though I'm going to need to re-work (more than
>> > simply
>> > extend) DataTable as I'll need to add additional rows.
>> >
>> > Thanks!
>> >
>> > Bill-
>> >
>> > On Tue, Oct 9, 2012 at 4:14 PM, Paul Bors <p...@bors.ws> wrote:
>> >
>> >> Must it be in a separate row? It doesn't make much sense to have
>> details in
>> >> a separate row unless you want to show the same columns.
>> >> And if you are going to show details for the same columns, then why
>> >> not just toggle each of the cell component between a simplified and
>> >> detailed
>> view?
>> >> I do it all the time when editing a table row, I toggle between
>> >> labels
>> and
>> >> form fields to set the contents of the table row.
>> >>
>> >> If you do want to show extra details that do not match the columns
>> >> in
>> your
>> >> table, use a pop-up or modal pop-up.
>> >>
>> >>
>> >> ~ Thank you,
>> >>   Paul Bors
>> >>
>> >> -----Original Message-----
>> >> From: William Speirs [mailto:wspe...@apache.org]
>> >> Sent: Tuesday, October 09, 2012 3:01 PM
>> >> To: users@wicket.apache.org
>> >> Subject: Dynamically Toggling a Details Row in a DataTable
>> >>
>> >> I would like to create a component that generates an additional row
>> >> in a DataTable for each existing row. This additional row will
>> >> contain
>> "details"
>> >> for the above row. I would like to have a column in the DataTable
>> >> that contains a link/button/etc which controls the visibility (display:
>> hidden
>> >> for that row) of the details row. Inside the details row, the
>> >> colspan
>> would
>> >> be set to the # of columns and contain an AjaxLazyLoadPanel such
>> >> that
>> when
>> >> the row is displayed the getLazyLoadComponent() method is called,
>> >> generating and fetching the proper component.
>> >>
>> >> So the DataTable will look like a normal DataTable, except when you
>> click
>> >> the link/button/etc a new row is shown and displays the Component
>> returned
>> >> from the call to the getLazyLoadComponent() method.
>> >>
>> >> How would I go about implementing this type of DataTable?
>> >>
>> >> Thanks in advance...
>> >>
>> >> Bill-
>> >>
>> >>
>> >> -------------------------------------------------------------------
>> >> -- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> >> For additional commands, e-mail: users-h...@wicket.apache.org
>> >>
>> >>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org

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

Reply via email to