我有一个ModelAdmin
带有MyDataObject
has_manyAnotherDataObject
和SilverStripe 网格字段扩展模块的控制
class TestAdmin extends ModelAdmin {
static $managed_models = array('MyDataObject');
static $url_segment = 'testadmin';
static $menu_title = 'TestAdmin';
}
class MyDataObject extends DataObject {
private static $db = array('Name' => 'Varchar(255)');
private static $has_many= array('AnotherDataObjects' => 'AnotherDataObject');
function getCMSFields() {
$fields = parent::getCMSFields();
if ($grid = $fields->dataFieldByName('AnotherDataObjects')) {
$grid->getConfig()
->removeComponentsByType('GridFieldAddExistingAutocompleter')
->addComponent(new GridFieldOrderableRows('Priority'));
$fields->removeByName('AnotherDataObjects');
$fields->insertAfter($grid,'Name');
}
return $fields;
}
}
class AnotherDataObject extends DataObject {
private static $db = array(
'Name' => 'Varchar(255)',
'Priority' => 'Int'
);
private static $has_one = array('MyDataObject' => 'MyDataObject');
}
我可以看到调用了“重新排序”,我将如何附加,例如......
alert('Reorder Complete!');
...在系统完成数据库更改后调用?