Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
WebGrid - Row Selection detection
posted

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 

Parents
  • 12025
    posted

    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.

    public void SelectedRowsChangeListener(SelectedRowsChangeEvent srce)

    {

         HtmlGridView grdControl = (HtmlGridView) srce.getComponent();

     

         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();

         srf.addSmartRefreshId(
    "MyForm:WebMenu1");

     

    }

     

    Hope this helps.

    -Taz.

Reply Children