Hi There
I would like to combine the row selection in the WebGrid with the menu pop up. Is there any chance to detect and render the menu options based on the user selection? As in before selection there may be x items in the menu and only if there is a row selected two more menu options will appear ( to view and edit that row)
For example is there a way to do something similar to the below:
<ig:menu id="popup1" popup="true" orientation="vertical"> <ig:menuItem value="Edit This Derivative" iconUrl="/resources/blank.gif"/> <ig:menuItem value="Create New" /> <ig:menuItem value="Go ElseWhere" />
<% if ( Something.getRowSelected() != null){
<ig:menuItem value="View This Row" "/> <ig:menuItem value="Edit This Row" /> <ig:menuItem value="Delete This Row" />
}
%>
</ig:menu>
Of course this means that the menue component is refreshed upon each selection
any idea?
Many thanks in advance
Shai Koren
Hello Shai,
You can handle the SelectedRowsChangeListener on the grid and check if there are rows selected in the grid, then you can add/remove items to the webmenu accordingly. In addition, you will have to add the WebMenu to the smart refresh manager so that the changes made on the server updates the menu on the client.
{
List selectedRows = grdControl.getSelectedRows();
if(selectedRows.size() > 0)
//Add Extra Items to Menu
else
//Remove Extra Items from Menu
//Add the client ID of the menu to the smart refresh manager to that it is updated on the client.
SmartRefreshManager srf = SmartRefreshManager.getCurrentInstance();
Hope this helps.
-Taz.
Hi Taz,
I have a similar issue. Basically I am using in Cell editing grid of Infragistics. I want to know the row on which the change is made (i.e the value of the each cell for which the change is made). Please sight ways as how to detect the rows without using checkboxes.
Further can you please detail me on the steps to implement SelectedRowsChangeListener (precisely how to register).
From the website I got these details "A listener interface for receiving RowSelectEvent. A class that is interested in receiving such events implements this interface, and then registers itself with the component by calling addRowSelectListener()."
Thanks in advance
Kaushal
Hello Kausal,
We are trying to simplify cell editing for the webgrid in our future releases that will help you have more control over the grid objects and easily track changes. In the existing model, you can capture value change events off of the editor component and go through its parent UIComponent chain to get a handle on the cell object and then the grid row object. So, for example, if you column uses and inputText like the following:
<ig:column>
<f:facet name="header">
<h:outputText value="Country" />
</f:facet>
<h:inputText value="#{DATA_ROW.country}" valueChangeListener="#{webgrid_hierarchicalGridPage.CountryChanged}"/>
</ig:column>
Then you can use "CountryChanged" listener to get hold of different grid object like this:
Cell c = (Cell)vce.getComponent().getParent();
RowItem ri = (RowItem) c.getParent();
You can register the SelectedRowsChangeListener just like how you would normally hook up any listener. Just use the grid attribute to hook it up to a backing bean method.
Taz.