Skip to content

Class column annotation and groups functionality. #507

Open
@WARrior-Alex

Description

@WARrior-Alex

In manual section Column Annotation for a class I see description of groups parameter:

Use this attribute to define more than one configuration for an Entity/Document. 
If no groups is defined, the annotation is attributed for all groups.
$source = new Entity('MyProjectMyBundle:MyEntity', 'my_group');

But in code looks like some logic bug with If no groups is defined, the annotation is attributed for all groups. when non-default group using. When loading Column annotation for property without group specification, it puts all annotations under custom group. But Column annotations for class it puts under default group.
Example:

/** 
 * Test
 * ...
 * @Grid\Column(id="custom_column", sortable=false, filterable=false, title="Custom Column") #No Groups Spec!!!
 * @GRID\Source(columns="<one set of columns with custom_column>") #No Groups Spec!!!
 * @GRID\Source(columns=<another set of columns with custom_column>", groups="some_custom_group") #With Groups Spec!
 * ...
 */
class Test
{
    ...
    /**
     * @GRID\Column(title="Some Property", type="number")  #No Groups Spec!!!
     */
    private $someProperty;
    ...
}

When I try to call

$source = new Entity('TestBundle:Test', 'some_custom_group');
...
$grid = $this->get('grid');
$grid->setSource($source);
$column = $grid->getColumn('custom_column');

it raises exception on last line:

Column with id "custom_column" doesn't exists.

Looking in code, I found in APY\DataGridBundle\Grid\Mapping\Driver\Annotation class that Column annotations for class puts custom_column column to default group only, not in specified in Entity constructor (but someProperty column was put to some_custom_group as requested). And you require to list all groups in Column annotations for class to resolve this issue.
BTW, the same is related to Source annotation too.
If this is correct, please update doc and add requirement to list all availabel groups in annotations (but this is not usefull).
If this is logic bug, I can provide PR to resolve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions