Hello,
I would like to ask you if the following scenario can be solved with AJAX functionality:
I have web grid (table) and each row contains delete action. When user clicks on delete icon then table row should be deleted, ideally without page refresh but only with web grid refresh (AJAX).
My current solution is over action listener. It works fine but the whole page must be refreshed.
<h:commandButton image="images/icon_remove.gif" value="#{DATA_ROW.id}" actionListener="#{assetController.removeAssetGroupListener}" />
It would be nice to have a NetAdvantage commands with AJAX support.
Thank you,
ANECT
Hi, ANECT!
It seems like you have to add grid.dataBind(); into your action listener, where grid is a com.infragistics.faces.grid.component.GridView property in the backing bean and your WebGrid is binded to it. When the dataBind() method is executed it will reconnect the grid to it's data source and the grid will refresh without the need of the whole page to be refreshed.
Regards!
But problem is that when user clicks on command then form data is submitted to the server and then action listener is processed. And if I would like to change web grid's data only (without page refresh) then I need to have different way how to do it.
Thank you for reply.
Anect
Hi, Anect!
<ig:link value="Delete" smartRefreshIds="grid" actionListener="#{webGridSelectionBean.onPressDelete}"></ig:link>
tag. Don't forget to apply a value to the smartRefreshIds attribute since only in that case only the mentioned components will refresh and not the whole page.
Great, it's what I have been searching for! (btw: I haven't found it in documentation)
And (I hope) last question - I need transfer item's id, something like the following:
<ig:link iconUrl="images/icon_remove.gif" value="#{DATA_ROW.id}" smartRefreshIds="groupMembershipTable" actionListener="#{assetController.removeAssetGroupListener}" /> But this solution has one disadvantage -ther aree image and value on the screen. Is there elegant way how transfer params via link?
Thank you very much!
Thank you.
Second solution is what I wanted to have.
And here I can offer another implementation that does not bind you to the necessity of setting the value attribute with the id of the row and so you can give it an arbitrary value like Delete in this example:
In JAVA:
public void onPressDelete2(ActionEvent e){
RowItem item = (RowItem) e.getComponent().getParent().getParent();
Clients client = (Clients) GridView.getDataRow(item);
while(it.hasNext()){
clientsList.remove(client);
}
In JSF:
<ig:link value="Delete" smartRefreshIds="grid" actionListener="#{webGridSelectionBean.onPressDelete2}"></ig:link>
I can offer you one implementation that in no case claims to be the most effective:
String id = (String) ((HtmlLink)e.getSource()).getValue();
Iterator it = clientsList.iterator();
Clients client = (Clients)it.next();
System.out.println("Record " + client.getId() + " will be removed!");
System.out.println("Record " + client.getId() + " was removed!");
<ig:link value="#{DATA_ROW.id}" smartRefreshIds="grid" actionListener="#{webGridSelectionBean.onPressDelete}"></ig:link>
I have table (grid view) and there is button for deletion on each row. When user clicks on the button then I would need transfer object's ID on certain row.I need information which object I should delete.
Or is there any other possibility how this do it?
Could you, please, explain what parameters and where you want to transfer?
Thanks!