APY / APYDataGridBundle

Symfony Datagrid Bundle
MIT License
493 stars 343 forks source link

Doctrine embeddable support #765

Open clubdesarrolladores opened 9 years ago

clubdesarrolladores commented 9 years ago

Hi, i have a very rich domain bussines modeled where i use doctrine embeddables, like Money or Document (a person identificator).

When i try creating the grid columns, i receive error from the generated dql.

Example:

    /**
     * @var float
     * @ORM\Embedded(class="WebFactory\Bundle\CommonBundle\ValueObject\Money")
     * @Grid\Column(title="Saldo")
     */
    protected $balance;

these works, but no output generated in cell.

    /**
     * @var float
     * @ORM\Embedded(class="WebFactory\Bundle\CommonBundle\ValueObject\Money")
     * @Grid\Column(title="Saldo", field="balance")
     */
    protected $balance;

balance is no a valid field or association.

    /**
     * @var float
     * @ORM\Embedded(class="WebFactory\Bundle\CommonBundle\ValueObject\Money")
     * @Grid\Column(title="Saldo", field="balance.amount")
     */
    protected $balance;

makes a dql join (it doesnt exists)

    /**
     * @var float
     * @ORM\Embedded(class="WebFactory\Bundle\CommonBundle\ValueObject\Money")
     * @Grid\Column(title="Saldo", field="balance_amount")
     */
    protected $balance;

similar to previous, the field doesnot exists.

In other hand, a column like that:

@Grid\Column(field="number.gambler.gamblerProfile.document")

(where "document" is a embeddable) is impossible to make this work.

I need make these columns filtrables and orderables.

Fuujin commented 9 years ago

I don't have much embeddables, so i don't know if you can use my advice:

I have a customer and a few embeddables like address. In the class annotation I use

@GRID\Source(columns="id, customerNumber.number,name,address.street, address.city,")

it works fine for address and customerNumber. But I don't know what you do with your embeddable, but for me it works fine just as if I use a relation.

tpettinotti commented 8 years ago

Hi, @Fuujin how did you manage to make it works ? I have the exact same issue as clubdesarrolladores. And the example you wrote give me an error, because of the Join on an unexisting relation.

Fuujin commented 8 years ago

@tpettinotti i found the reason my solution works. if you fetch the data beforehand and then set the results on source-entity it works fine. May not always be possible, so support for embeddables would be great.