public function init(DatagridInterface $datagrid)
    {
        if (null === $data = $datagrid->getData()) {
            throw new InvalidArgumentException('No data provided for the view.');
        }

        $columns = $datagrid->getColumns();

        foreach ($columns as $column) {
            $this->columns[$column->getName()] = $column->createHeaderView($this);
        }

        if (!isset($this->vars['row_vars'])) {
            $this->vars['row_vars'] = [];
        }

        foreach ($data as $id => $value) {
            $this->rows[$id] = $row = new DatagridRowView($this, $columns, $value, $id);
            $row->vars = $this->vars['row_vars'];
        }
    }