如何在MIGX网格中创建可编辑的列表框列?

时间:2018-06-13 14:48:05

标签: modx migx

我有一个列表框类型formtab工作正常,它从弹出窗口添加/编辑等:

{
          "MIGX_id":52,
          "field":"category",
          "caption":"Category",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"listbox",
          "validation":"required",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"@EVAL return 'Choose Category==||' . $modx->runSnippet('migxLoopCollection',array('packageName'=>'projects','classname'=>'ProjectCategory','tpl'=>'@CODE:[[+category]]==[[+id]]','outputSeparator'=>'||'));",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        }

所以你可以看到它从数据库表中获取它的选项:

<object class="ProjectCategory" table="bigblock_project_category" extends="xPDOSimpleObject">
        <field key="category" dbtype="char" precision="50" phptype="string" null="false" />   
        <field key="sort" dbtype="int" precision="10" phptype="integer" null="false" default="0" /> 
        <aggregate alias="Project" class="Project" local="id" foreign="category" cardinality="many" owner="local" default="0" />   
    </object>

这很有效 - 显示选项 - 一切都很开心。

现在,我找到了几篇文章&amp;关于如何在migx网格视图列中呈现类别名称(而不是它的id)的帖子似乎很简单。

但是:

我需要网格列视图中的类别是可从网格中编辑的列表框(选择字段)。

怎么做的?

更新 因此,如果我使用连接的class_field作为列字段名称,并且它在网格视图中显示类别名称,那么现在某种程度上“有点”工作 - 很棒......但是,如果我单击/双击项目下降下面的列表是空白的。如果我将“dataIndex”:“ProjectCategory_category”更改为“dataIndex”:“category”,则会正确填充下拉列表并且我可以更改/编辑项目(并验证它们在数据库中是否正确)

{
      "MIGX_id":13,
      "header":"Project Category",
      "dataIndex":"ProjectCategory_category",
      "width":"",
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"switchOption",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":"this.listboxEditor"
    }

更进一步,我现在需要的是知道如何正确呈现类别名称并正确填充列表框。

0 个答案:

没有答案
相关问题