diff --git a/code/GridFieldBulkManager.php b/code/GridFieldBulkManager.php index 98482e5..d3fc3fd 100644 --- a/code/GridFieldBulkManager.php +++ b/code/GridFieldBulkManager.php @@ -37,7 +37,9 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr function getColumnMetadata($gridField, $columnName) { - return array('title' => null); + if($columnName == 'BulkSelect') { + return array('title' => 'Select'); + } } /* // GridField_ColumnProvider */ diff --git a/code/GridFieldBulkManager_Request.php b/code/GridFieldBulkManager_Request.php index f80be55..3e1e29a 100644 --- a/code/GridFieldBulkManager_Request.php +++ b/code/GridFieldBulkManager_Request.php @@ -65,7 +65,23 @@ class GridFieldBulkManager_Request extends RequestHandler { public function unlink(SS_HTTPRequest $request) { + $recordList = $this->getPOSTRecordList($request); + $recordClass = $this->gridField->list->dataClass; + $recordForeignKey = $this->gridField->list->foreignKey; + //$recordForeignID = $this->gridField->list->foreignID; + $result = array(); + foreach ( $recordList as $id ) + { + $record = DataObject::get_by_id($recordClass, $id); + $res = $record->setField($recordForeignKey, 0); + $record->write(); + array_push($result, array($id => $res)); + } + + $response = new SS_HTTPResponse(Convert::raw2json(array($result))); + $response->addHeader('Content-Type', 'text/plain'); + return $response; } public function delete(SS_HTTPRequest $request)