Hi Sven,

Sven Pfeiffer wrote:

Because I don't know if the user wants to enter 1, 5, 10 or 100 items I would like to add a "add Rows" Button to my page that adds 5 Rows to my formtable.

Currenty I see two ways to accomplish this:
1) adding an ActionButton in its listener adds 5 "empty" Items to the FormTable


This option would be the easiest to implement. In your ActionButton event you create 5 new Items in your database (or storage of choice). However because the ActionButton listener is fired in the onProcess event, you would already have set the Table's rowList. So you would need to manipulate the FormTable rowList in the ActionButton listener in order to reflect the 5 new rows. Alternatively you could do a redirect to the same page in the ActionButton listener which will also refresh the FormTable and pickup the 5 new rows.



2) adding 5 Rows using Javascript

I would prefer solution 2).

Now I was wondering if the Click-FormTable would recognize that there are more rows in the table.


FormTable is driven by its rowList so it won't recognize the new rows or bind their values. What you can try is add a HiddenField to the Form which tracks how many new rows were added. You can use JavaScript to update the HiddenField every time new rows are added. In your Page you need to check the HiddenField value and create that amount of new Items before setting the FormTable rowList. Further if you inspect the HTML source code you'll note that FormTable rows are indexed based. Thus the fields in row 1 will be suffixed with "_0" and so on. You need to increment the index when adding new rows.

Hope this helps.

kind regards

bob

Reply via email to