Spark Menu Disable Style

Post Reply
kahlon1005
Posts: 41
Joined: 19 Jun 2013, 00:54

26 Jun 2015, 10:01

I am populating Spark layout menu from model POJO. During this based on some creteria I had disabled few menu element at leaf level. Which works !!!. But the problem is that there style remains unchanged meaning the disabled and enable menu element style remain same which is kind of a problem from user experience point of view.
PrimeFaces 5.3 | Spark 2.1 | Wildfly 10.0 | Mojarra 2.2.0 | Eclipse | Prime Faces Extension 3.2.0 | Omnifaces 2.0 | Java 1.8

User avatar
aragorn
Posts: 3283
Joined: 29 Jun 2013, 12:38

26 Jun 2015, 10:10

A few menuItem is disabled="true" in ps:menu. Right?
Exp;

Code: Select all

<ps:menu>
   <p:submenu label="Spark Theme" icon="fa fa-rocket">
      <p:menuitem value="Forms" icon="fa fa-file-text-o" outcome="forms" />
      <p:menuitem value="Misc" icon="fa fa-stack-overflow" outcome="misc" disabled="true" />
   </p:submenu>
...

kahlon1005
Posts: 41
Joined: 19 Jun 2013, 00:54

26 Jun 2015, 19:17

Right. The expectation is the disabled style should apply for disabled menu elements When element is disabled from bean or page.

From xhtml

Code: Select all

<p:menuitem value="Misc" icon="fa fa-stack-overflow" outcome="misc" disabled="true" />

From bean

Code: Select all

 
leafNode.setDisabled(true);
 subMenu.addElement(leafNode);
PrimeFaces 5.3 | Spark 2.1 | Wildfly 10.0 | Mojarra 2.2.0 | Eclipse | Prime Faces Extension 3.2.0 | Omnifaces 2.0 | Java 1.8

User avatar
aragorn
Posts: 3283
Joined: 29 Jun 2013, 12:38

28 Jun 2015, 00:46

Thanks for the sample. I've replicated the issue. I think you can try with this changes;
- please change in encodeMenuItem function of SparkMenuRenderer;

Code: Select all

protected void encodeMenuItem(FacesContext context, AbstractMenu menu, MenuItem menuitem, int marginLevel) throws IOException {
        ...
        String styleClass = "Animated05";
        if(marginLevel >= 1) {
            styleClass = styleClass + " menuLevel" + marginLevel;
        }

        if(disabled) { // Added
            styleClass = styleClass + " ui-state-disabled";
        }
        
        writer.startElement("a", null);
        ....
- please add the css code in your layoutmenu.xhtml or spark-layout-* file;

Code: Select all

<style type="text/css">
             #layout-menu li ul li a.ui-state-disabled {
                background-color: transparent !important;
                color: #778d9b !important;
            }
            #layout-menu li ul li:hover > a.ui-state-disabled {
                background-color: transparent !important;
                color: #778d9b !important;
            }
</style>


We will add a similar solution for next version.

mmorthosoft1
Posts: 4
Joined: 27 Mar 2014, 09:57

14 Dec 2016, 18:24

still not in the current version of spark 2.1.2
I need this fix and you promised to include it in next release.

User avatar
aragorn
Posts: 3283
Joined: 29 Jun 2013, 12:38

15 Dec 2016, 11:06

Sorry, I added this fix into next version; https://github.com/primefaces/layouts/issues/138

mmorthosoft1
Posts: 4
Joined: 27 Mar 2014, 09:57

15 Dec 2016, 14:09

thank you very much Sir.

User avatar
aragorn
Posts: 3283
Joined: 29 Jun 2013, 12:38

15 Dec 2016, 14:09

You're welcome!

malkova
Posts: 2
Joined: 23 Apr 2017, 15:52

27 Apr 2017, 14:47

Long been looking for this information, thank you guys for the post!!!

User avatar
aragorn
Posts: 3283
Joined: 29 Jun 2013, 12:38

01 May 2017, 12:19

Thanks ;)

Post Reply

Return to “Spark”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests