[SOLVED] Add a new row to a datatable in edit mode

UI Components for JSF
Post Reply
daniel.camargo
Posts: 24
Joined: 22 Oct 2010, 20:00

22 Nov 2010, 21:52

Hi,

I'd like to know if there is a way to add a new row to a datable and make this row editable without clicking on the edit button (some kind of javascript call).

Could anyone help me on that?
Last edited by daniel.camargo on 23 Nov 2010, 12:59, edited 1 time in total.
JSF2 - Primefaces-3.1.RC1

daniel.camargo
Posts: 24
Joined: 22 Oct 2010, 20:00

23 Nov 2010, 12:58

I can't say that this is the best way to do it but it's working:

Code: Select all


<p:commandLink
	action="#{mBean.addNewRow}"
	value="Add new row" styleClass="icon icon-add"
	update="items-list messages" oncomplete="editLastDatatableRow();" />

function editLastDatatableRow(){
	jQuery('.ui-datatable-data tr').last().find('span.ui-icon-pencil').each(function(){
		jQuery(this).click()
	});
}

JSF2 - Primefaces-3.1.RC1

callahan
Posts: 768
Joined: 27 May 2010, 22:52

23 Nov 2010, 13:04

That's a good trick. It should be in the DataTables JavaScript client side API.

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

23 Nov 2010, 16:09

Thanks for posting your solution. Being able to control whether the row is in edit mode is a good feature.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests