primefaces update table row after cell edit - primefaces

I am using primefaces datatbale cell editing , when I edit the a cell the next column of that row should display a calculated value which is calculated from this cell value,I am using celleditEvent to invoke a listener using
Please advice in my listener is there a way to retrieve the id of the tr and add to request context to update this row. Please advice.
public void onCellEdit(CellEditEvent cellEditEvent){
RequestContext.getCurrentInstance().update(((DataTable)cellEditEvent.getSource()).getClientId());
}
in this event method it it possible to retrieve html id of the tr element containing this cell.

Try to use OmniFaces with PrimeFaces
Take a look at this : http://showcase.omnifaces.org/utils/Ajax

Related

Keep value in textboxes after adding row

i am currently working on to display the value in textboxes after adding row to the table. I am new to angular and seems i could not find the solution. At the moment, everytime i click on the Add button, the table will add new row but somehow the value that i have entered previously are gone. I need to make the value stays in the textbox every time the user adds new row.
Here is the source code that i have done:
https://stackblitz.com/edit/angular-hxduqp
Thank you.
That happens when you have multiple inputs with the same name.
One way to fix it is by giving your input names a suffix of your iterator i:
<input ... [name]="'from' + i" ...>
Here is your StackBlitz corrected:
https://stackblitz.com/edit/angular-bgdgpr?file=src/app/app.component.html
You just remove the name from the form control if not required else you need to provide the unique name to each control.
Working copy is here - https://stackblitz.com/edit/angular-gpq9nc

Replace datagrid values?

Hi I am trying to overwrite the value in a datagrid I have with a new one. I tried the following code:
datagrid1.addItem({Column1: "support"});
And this causes the new value to be added to the row below it instead. What am I doing wrong?

Add HTML 5 data attribute to a newly created row when table is using datatable js

I have a HTML table with each row with HTML5 data attribute. The table is using jQuery Datatables plug-in. Now when I am adding a new row on a click of button how to add HTML5 data attribute to it again. The data attribute value is specified by the user.
Data attribute write:
$('#categories-table').dataTable
'createdRow': (row, data, dataIndex) ->
$(row).attr('data-category-id', data[0])
Data attribute read:
$('#categories-table tbody').on 'click','tr', () ->
console.log $(this).data('category-id')
You may want to look at http://datatables.net/reference/option/columns.createdCell
that's a callback for once the cell is created so you can modify it and add your custom attributes or for the row http://datatables.net/reference/option/createdRow
(using the current v1.10.4)

Prevent caching data of a dataTable

I have a ice:dataTable and in each row, there is a inputText. The record list is updated every time when fire a valueChangeListener on some other component.
When it resets the record list, browser shows the previous values for inputText fields in table rows.
I tried both Filter and <meta/> tags. It didn't work for me.
Can somebody tell me how to get rid of this problem?
(Backing bean keeps the actual record list)
This is a JSF problem, take a look at the following answer for details
Input fields hold previous values only if validation failed
To make it simple JSF keeps values in the partialViewContext so all what you have to do to reset all components in the partialViewContext
or if you are using primefaces you can simply add < p:resetInput target="tableId"/> to the field (nested inside) or if you are using OmiFaces then you can use ResetInputAjaxActionListener

JComboBox as CellRenderer does not set the correct value

I'm using a JComboBox as CellRenderer in my JTable.
Everything works fine the JComboBox displays the correct item for the corresponding row.
The problem I am currently working on is that when I choose a new value in the JComboBox (for example row 9) the value is set correctly, but when I try to change the value in the next row, the JComboBox (for example in row 10) automatically sets the value of the row before.
I created a DropDownCellRenderer class which extends JComboBox and implements TableCellRenderer, I thought that is enough, but it seems that the DropDownCellRenderer-object is the same for every row.
table.getColumnModel().getColumn( 3 ).setCellRenderer( new DropDownCellRenderer() );
table.getColumnModel().getColumn( 3 ).setCellEditor( new DefaultCellEditor( new DropDownCellRenderer() ) );
How can I avoid that every row uses the same object?
Looked at your renderer's source code.
I don't think you have to look up the Product by name. The value passed to you is the Product, which is coming from your table model (if it is implemented correctly). Just set the value as selected item and it should work.
To make renderer behave correctly, change its foreground and background colors according to isSelected parameter. The code should look like:
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
Make your initial array of values an argument of the constructor. This will transform your renderer into universal combobox renderer.
It sounds like you're saving and displaying values within the combo box itself, not from the model of the table. When you set a value and save a combobox value you need to update the model