addColumns 中的名称

Name in addColumns

当我将 属性 "addColumns" 放在一个片段中时遇到问题,因为它没有显示 属性 的名称。此 属性 定义为 "joinByOne"。一个发生在我身上的例子:

我试着把标题的名字加上 "partial" 属性 但我没听懂。

addColumns: [

    {
    name: '_type',
    label: 'Type',

    //partial: articleType => articleType.map(articleType => articleType.title).join(' ')

    /*partial: function(title) {
        if (!value) {
        // Don't crash if updatedAt is missing
        return '';
        }
        return self.partial('specialist', { title: title });
    }*/


    },
]

是否有有效的方法将标题放入列中?

您的部分接收连接的值,您可以调用它 _type。由于它是一个 joinByOne,因此值将是整个连接的 object,而不仅仅是它的标题。

所以你只需要写:

partial: function(_type) {
  if (!_type) {
    return 'None';
  } else {
    return _type.title;
  }
}

请注意,_type 始终有可能为空,即使您将其设置为 required,因为有人可能会将类型本身移至垃圾箱等。