contributte / contributte/datagrid

Doctrine & TreeView

Open
#826 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
296
Forks
215
PR merge metrics
No merged PRs in 30d

Description

Hi treeview does not work with doctrine

My Entity

class MaterialCategory implements IEntity
{
    use SmartObject;
    use TId;
    use TName;
    use TSlug;

    /**
     * @var MaterialCategory|null
     * @ORM\ManyToOne(targetEntity="MaterialCategory", inversedBy="children")
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
     */
    private $parent;

    /**
     * @var Collection
     * @ORM\OneToMany(targetEntity="MaterialCategory", mappedBy="parent")
     */
    private $children;

    /**
     * @ORM\OneToMany(targetEntity="Material", mappedBy="category",cascade={"all"})
     */
    private $material;

    /**
     * MaterialCategory constructor.
     */
    public function __construct()
    {
        $this->children = new ArrayCollection();
        $this->material = new ArrayCollection();
    }

    /**
     * @return MaterialCategory|null
     */
    public function getParent(): ?MaterialCategory
    {
        return $this->parent;
    }

    /**
     * @param MaterialCategory|null $parent
     * @return $this
     */
    public function setParent(?MaterialCategory $parent)
    {
        $this->parent = $parent;
        return $this;
    }

    /**
     * @return Collection
     */
    public function getChildren(): Collection
    {
        return $this->children;
    }
}

DQL

SELECT MaterialMaterialCategory FROM app\modules\Materials\entities\MaterialCategory MaterialMaterialCategory WHERE MaterialMaterialCategory.parent IS NULL

Datagrid show only root rows.
hasChildrenCallback and getChildrenCallback never run (callbacks use $entity->getChildren()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown DQL query with the MaterialCategory entity and tracing the TreeView hasChildrenCallback and getChildrenCallback behavior. Compare the Doctrine entity mappings with the datagrid's tree-loading path; done means root rows display their children through the callbacks without breaking the Doctrine-backed grid.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.