11 Replies Latest reply on Nov 12, 2009 6:12 AM by btj

    Disabling entries in a context menu for table rows?

      I am looking for a way to disable menu entries in a context menu that is displayed for each row in a rich:dataTable but haven't found a solution that works yet... Isn't this possible?

      A value in each row decides whether a menu entry is disabled or not but not sure how to program this...

      Any suggestions?



      Regards,

      BTJ

        • 1. Re: Disabling entries in a context menu for table rows?

          Anyone? Isn't this possible??

          BTJ

          • 2. Re: Disabling entries in a context menu for table rows?
            nbelaevski

            Hi BTJ,

            Menu item has disabled attribute. Have you tried it?

            • 3. Re: Disabling entries in a context menu for table rows?

              Yes, but the problem is not that... The problem is setting the disabled value based on one value for each row.. I.e. for some rows the menu item should be enabled but for some others it should be disabled...
              I can't find a way to get hold on the row data so I can set the correct value for the disabled attribute...


              BTJ

              • 4. Re: Disabling entries in a context menu for table rows?
                nbelaevski

                What is page code?

                • 5. Re: Disabling entries in a context menu for table rows?

                  by page code you mean an example? if so, here is an example..:

                  <rich:dataTable var="vare" value="#{articleSearchController.articles}">
                  .....rows data.....
                   <rich:componentControl event="onRowContextMenu" for="contextmenu" operation="show" >
                   <f:param value="#{vare.varenummer}" name="rowVarenr"/>
                   <f:param value="#{vare.existInSortiment}" name="exists"/>
                   </rich:componentControl>
                  </rich:dataTable>
                  <rich:contextMenu attached="false" submitMode="ajax" id="contextmenu" disableDefaultMenu="true" hideDelay="0">
                   <rich:menuItem value="#{msgs.edit_price_on_article}" action="#{myArticleSearchController.editArticle}" disabled="{!exists}">
                   <a4j:actionparam value="{rowVarenr}" name="varenr4" assignTo="#{myArticleSearchController.chosenVarenr}"/>
                   </rich:menuItem>
                   <rich:menuItem id="menudelete" value="#{msgs.delete_article}" action="delete" disabled="{!exists}">
                   <a4j:actionparam value="{rowVarenr}" name="varenr5" assignTo="#{myArticleSearchController.chosenVarenr}" />
                   <rich:componentControl for="modConfirm" attachTo="menudelete" operation="show" event="onclick"/>
                   </rich:menuItem>
                  </rich:contextMenu>
                  



                  This I thought perhaps should work but it doesn't....


                  BTJ


                  • 6. Re: Disabling entries in a context menu for table rows?
                    nbelaevski

                    Output disabled/not disabled menu items and switch between them via CSS. Note: you should do the check for disabled items on the server also.

                    • 7. Re: Disabling entries in a context menu for table rows?

                      Do you have an example on how to do this?

                      I tried to do it like this..:

                      <rich:componentControl event="onRowContextMenu" for="contextmenu" operation="show" >
                       <f:param value="#{vare.varenummer}" name="rowVarenr"/>
                       <f:param value="#{vare.finnesISortiment ? 'hidden' : 'none'}" name="show_finnes"/>
                       <f:param value="#{vare.finnesISortiment ? 'none' : 'hidden'}" name="show_finnes_ikke"/>
                      </rich:componentControl>
                      
                      
                      <rich:contextMenu attached="false" submitMode="ajax" id="contextmenu" disableDefaultMenu="true" hideDelay="0">
                       <rich:menuItem value="#{msgs.add_article_to_sortiment}" action="#{articleSearchController.addArticle}" reRender="articlesearchgrid,articlestablegroup" style="display: {show_finnes_ikke};">
                       <a4j:actionparam value="{rowVarenr}" name="varenr6" assignTo="#{articleSearchController.chosenVarenr}"/>
                       </rich:menuItem>
                       <rich:menuItem value="#{msgs.add_article_to_sortiment}" action="add" style="display: {show_finnes};" disabled="true"/>
                       <rich:menuItem value="#{msgs.edit_price_on_article}" action="#{articleSearchController.editArticle}" style="display: {show_finnes};" disabled="false">
                       <a4j:actionparam value="{rowVarenr}" name="varenr4" assignTo="#{articleSearchController.chosenVarenr}"/>
                       </rich:menuItem>
                       <rich:menuItem value="#{msgs.edit_price_on_article}" action="edit" style="display: {show_finnes_ikke};" disabled="true"/>
                       <rich:menuItem id="menudelete" value="#{msgs.delete_article_from_sortiment}" style="display: {show_finnes};" disabled="false" action="delete">
                       <a4j:actionparam value="{rowVarenr}" name="varenr5" assignTo="#{articleSearchController.chosenVarenr}"/>
                       <rich:componentControl for="modConfirm" attachTo="menudelete" operation="show" event="onclick"/>
                       </rich:menuItem>
                       <rich:menuItem value="#{msgs.delete_article_from_sortiment}" style="display: {show_finnes_ikke};" disabled="true"/>
                      </rich:contextMenu>
                      



                      And it kind of work... it displays the context menu with the correct items disabled but the third item is always displayed disconnected from the contxt menu and displayed under the table...
                      What am I missing?


                      BTJ


                      • 8. Re: Disabling entries in a context menu for table rows?
                        ilya_shaikovsky

                        this is caused by issue in 3.3.2 SR1. please check under 3.3.3 snapshot.

                        • 9. Re: Disabling entries in a context menu for table rows?

                          How stable is the 3.3.3 snapshot?

                          BTJ

                          • 10. Re: Disabling entries in a context menu for table rows?
                            ilya_shaikovsky

                            all the branch under stabilization works only. and BETA should be available soon. You will get just a few bugfixes changes after switching.

                            • 11. Re: Disabling entries in a context menu for table rows?

                              Ok, I will try the snapshot and see how it goes... Thx... :)

                              BTJ