TieredMenu: command only on leaf items

UI Components for Angular
Post Reply
erop
Posts: 2
Joined: 14 Apr 2018, 09:57

25 Apr 2018, 17:09

Hi!
I'm using TieredMenu which is populated with MenuItems tree generated from database. I need to handle choosing/clicking only leaf items as only leaf items keep database ids as 'id' property. Looks like i need to append `command` MenuItem' property to each of leaf items. But it does not sound good. Is it possible to set the command at the root level but to be called only on leaf items?

erop
Posts: 2
Joined: 14 Apr 2018, 09:57

26 Apr 2018, 09:24

Looks like the following solution should be OK:
  • Add non-documented (click) event handler to <p-tieredMenu> element
  • In click handler check event.target.id first
  • If id not exists find parent element by CSS selector 'a.ui-menuitem-link' and grab its id

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests