gpt4 book ai didi

SilverStripe 删除 CSV 导出按钮

转载 作者:行者123 更新时间:2023-12-04 05:31:53 24 4
gpt4 key购买 nike

我正在尝试删除 导出为 CSV GridField 顶部的按钮在 ModelAdmin .

我似乎找不到创建按钮的类( GridFieldExportButton 对吗?)。我猜有一个函数可以用我不熟悉的按钮/“ Action ”填充 GridField。

最佳答案

要删除关系的脚手架 GridField...

class MyDataObject extends DataObject {

...

private static $has_many= array(
'OtherDataObjects' => 'OtherDataObject'
);

...

function getCMSFields() {
$fields = parent::getCMSFields();

if($grid = $fields->dataFieldByName('OtherDataObjects'))
$grid->getConfig()
->removeComponentsByType('SilverStripe\Forms\GridField\GridFieldExportButton');

return $fields;
}

...

}

如果您正在制作 GridField 那么只需在创建字段时添加它...
$gridField->getConfig()->removeComponentsByType('SilverStripe\Forms\GridField\GridFieldExportButton'); 

如果您正在寻找一个不在数据对象编辑表单中的网格字段,并且实际上...
class MyAdmin extends ModelAdmin {

...

function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);

if($this->modelClass == 'MyDataObjectName') {
$form->Fields()
->fieldByName($this->sanitiseClassName($this->modelClass))
->getConfig()
->removeComponentsByType('SilverStripe\Forms\GridField\GridFieldExportButton');
}
return $form;
}

...
}

将 model_importers 设置为空将执行相反的操作并删除导入...
class MyAdmin extends ModelAdmin {

...

static $model_importers = array();

...
}

关于SilverStripe 删除 CSV 导出按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38374073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com