Table Decorator : How to question


#1

Hi,

I am looking for best implementation of following case.

In my some view I have

  1. a \atk4\ui\Grid and
  2. A Class public variable containing array
    array (size=2) ‘Active’ => array (size=4) ‘view’ => boolean true ‘edit’ => boolean true ‘delete’ => array (size=1) 0 => string ‘4’ (length=1) ‘deactivate’ => boolean false ‘InActive’ => array (size=4) ‘view’ => boolean false ‘edit’ => boolean false ‘delete’ => boolean false ‘activate’ => boolean false

Basically, this array contains Various status of a model and what action user is allowed to take on that status. ‘view’, ‘edit’,‘delete’ is not of concerned now but deactivate/activate is the catch here.

My Query is How do I create and add such Decorator that adds Menu/DropDown on status column showing Status and DropDown Opens Menu based on that public array logic.

The underdevelopment Controller is at https://github.com/we-nebula/ecomm/blob/master/development/we-nebula/ecomm/src/Controller/Acl.php and is a recreation of our 4.3 ACL Controller in Atk4\ui.

Best Practice Direction needed …


#2

Hi! I’m not sure if this will work to your specific use case with Menus/DropDowns but you can add a Callback function that can make a table decorator conditional. I’m using it now on a table to make certain items be a URL link instead of only text. I took the Callback function examples from the documentation and tailored it for this purpose.