如何在数据网格、Orocommerce 中将数据源类型导出为数组

问题描述

我从 datagrid.yml 创建了一个基于数组的数据网格,但我不知道如何将数据网格的数据导出到 csv 或 excel 文件。 我在侦听器中使用 onBuildAfter 方法将数组数据填充到数据网格中。

datagrid.yml:

 test-demo-lookup-grid:
    options:
        export:
            csv: { label: oro.grid.export.csv }
    source:
        type: array
    columns:
        id:
            label: 'ID'
        ot:
            label: 'OT'

听众:

public function onBuildAfter(BuildAfter $event)
{
    $datagrid = $event->getDatagrid();
    $datasource = $datagrid->getDatasource();

    if (!$datasource instanceof ArrayDatasource) {
        throw new UnexpectedTypeException($datasource,ArrayDatasource::class);
    }
    $recordsJsonObj = $this->getParameter($datagrid,'records');

    if (!empty($recordsJsonObj)) {
        $records = json_decode($recordsJsonObj);

        $datasource->setArraySource($records);
    }
}
enter code here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)