Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen committed Feb 25, 2016
1 parent c5b7ed7 commit 671ea19
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 70 deletions.
71 changes: 1 addition & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,7 @@

## 1. Recent Changes

### In-place editing

In-place editing for text, datetime and boolean fields added (before usage you should manually include dependent x-editable js and css files).

Example:

```php
->add('title', 'column', array(
'title' => 'Titel',
'editable' => true
))
->add('publishedAt', 'datetime', array(
'title' => 'PublishedAt',
'name' => 'daterange',
'date_format' => 'll',
'editable' => true
))
->add('visible', 'boolean', array(
'title' => 'Visible',
'editable' => true
))
```

<div style="text-align:center"><img alt="Screenshot" src="https://github.com/stwe/DatatablesBundle/raw/master/Resources/images/editable.jpg"></div>

### Token for multiselect actions

The multiselect ajax request sends now a CSRF-Token.

Update your bulk-actions like this:

```php
/**
* Bulk delete action.
*
* @param Request $request
*
* @Route("/bulk/delete", name="post_bulk_delete")
* @Method("POST")
*
* @return Response
*/
public function bulkDeleteAction(Request $request)
{
$isAjax = $request->isXmlHttpRequest();

if ($isAjax) {
$choices = $request->request->get('data');
$token = $request->request->get('token');

if (!$this->isCsrfTokenValid('multiselect', $token)) {
throw new AccessDeniedException('The CSRF token is invalid.');
}

$em = $this->getDoctrine()->getManager();
$repository = $em->getRepository('AppBundle:Post');

foreach ($choices as $choice) {
$entity = $repository->find($choice['value']);
$em->remove($entity);
}

$em->flush();

return new Response('Success', 200);
}

return new Response('Bad Request', 400);
}
```
Nothing since Version 0.10.

## 2. Screenshots

Expand Down
44 changes: 44 additions & 0 deletions Resources/doc/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ SgDatatablesBundle:Column:multiselect.html.twig

### Example

#### Datatables class

``` php
$this->getColumnBuilder()
->add(null, 'multiselect', array(
Expand Down Expand Up @@ -458,6 +460,48 @@ $this->getColumnBuilder()
))
;
```

#### Controller

```php
/**
* Bulk delete action.
*
* @param Request $request
*
* @Route("/bulk/delete", name="post_bulk_delete")
* @Method("POST")
*
* @return Response
*/
public function bulkDeleteAction(Request $request)
{
$isAjax = $request->isXmlHttpRequest();

if ($isAjax) {
$choices = $request->request->get('data');
$token = $request->request->get('token');

if (!$this->isCsrfTokenValid('multiselect', $token)) {
throw new AccessDeniedException('The CSRF token is invalid.');
}

$em = $this->getDoctrine()->getManager();
$repository = $em->getRepository('AppBundle:Post');

foreach ($choices as $choice) {
$entity = $repository->find($choice['value']);
$em->remove($entity);
}

$em->flush();

return new Response('Success', 200);
}

return new Response('Bad Request', 400);
}
```
___

## 9. Image column
Expand Down
4 changes: 4 additions & 0 deletions Resources/doc/editable.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# In-place editing

In-place editing for text, datetime and boolean fields added (before usage you should manually include dependent x-editable js and css files).

<div style="text-align:center"><img alt="Screenshot" src="https://github.com/stwe/DatatablesBundle/raw/master/Resources/images/editable.jpg"></div>

## 1. Setup in-place editing

### routing.yml
Expand Down

0 comments on commit 671ea19

Please sign in to comment.