Permalink
Browse files

Add a default datatable templete without twitter bootstrap

  • Loading branch information...
1 parent fe7d1e2 commit b5113c4a119953204471c0055ae101e3a62c9287 @PedroTroller PedroTroller committed Nov 2, 2012
@@ -1,6 +1,6 @@
<thead>
{% for id, title in elements|toHeadersArray(options) %}
- <th id="header-{{ id }}">{{ title }}</th>
+ {% block thead %}<th id="header-{{ id }}">{{ title }}</th>{% endblock %}
{% endfor %}
</thead>
<tbody>
@@ -0,0 +1,60 @@
+{% block td %}
+ <tr>
+ {% set element = element|toArray(options) %}
+ {% for id, title in headers %}
+ <td>
+ {% if element[id] is defined %}{{ element[id] }}{% endif %}
+ </td>
+ {% endfor %}
+ {% if routes|length > 0 %}
+ <td>
+
+ {% if routes.show is defined %}
+ {% block route_show %}
+ {% set parameters = [] %}
+ {% for name, attrib in routes.show.parameters %}
+ {% set parameters = parameters|merge({name: element[attrib]}) %}
+ {% endfor %}
+ <a href="{{ path(routes.show.path, parameters) }}" {% if routes.show.label is defined %}title="{{ routes.show.label }}"{% endif %}>
+ {% if routes.show.label is defined %}
+ {{ routes.show.label }}
+ {% endif %}
+ </a>
+ {% endblock %}
+ {% endif %}
+
+ {% if routes.edit is defined %}
+ {% block route_edit %}
+ {% set parameters = [] %}
+ {% for name, attrib in routes.edit.parameters %}
+ {% set parameters = parameters|merge({name: element[attrib]}) %}
+ {% endfor %}
+ <a href="{{ path(routes.edit.path, parameters) }}" {% if routes.edit.label is defined %}title="{{ routes.edit.label }}"{% endif %}>
+ {% if routes.edit.label is defined %}
+ {{ routes.edit.label }}
+ {% endif %}
+ </a>
+ {% endblock %}
+ {% endif %}
+
+ {% if routes.delete is defined %}
+ {% block route_delete %}
+ {% set parameters = [] %}
+ {% for name, attrib in routes.delete.parameters %}
+ {% set parameters = parameters|merge({name: element[attrib]}) %}
+ {% endfor %}
+ <form method="post" action="{{ path(routes.delete.path, parameters) }}" style="margin:0;display:inline" >
+ <input type="hidden" name="_method" value="DELETE" />
+ <button type="submit" {% if routes.delete.label is defined %}title="{{ routes.delete.label }}"{% endif %}>
+ {% if routes.delete.label is defined %}
+ {{ routes.delete.label }}
+ {% endif %}
+ </button>
+ </form>
+ {% endblock %}
+ {% endif %}
+
+ </td>
+ {% endif %}
+ </tr>
+{% endblock %}
@@ -0,0 +1 @@
+{% extends 'KnpRadBundle:Twig:Datatable/Default/datatable.html.twig' %}
@@ -0,0 +1,40 @@
+{% extends 'KnpRadBundle:Twig:Datatable/Default/datatable_row.html.twig' %}
+
+{% block route_show %}
+ {% set parameters = [] %}
+
+ {% for name, attrib in routes.show.parameters %}
+ {% set parameters = parameters|merge({name: element[attrib]}) %}
+ {% endfor %}
+
+ <a href="{{ path(routes.show.path, parameters) }}" {% if routes.show.label is defined %}title="{{ routes.show.label }}"{% endif %}>
+ <i class="icon-eye-open"></i>
+ </a>
+ {% endblock %}
+
+{% block route_edit %}
+ {% set parameters = [] %}
+
+ {% for name, attrib in routes.edit.parameters %}
+ {% set parameters = parameters|merge({name: element[attrib]}) %}
+ {% endfor %}
+
+ <a href="{{ path(routes.edit.path, parameters) }}" {% if routes.edit.label is defined %}title="{{ routes.edit.label }}"{% endif %}>
+ <i class="icon-pencil"></i>
+ </a>
+{% endblock %}
+
+{% block route_delete %}
+ {% set parameters = [] %}
+
+ {% for name, attrib in routes.delete.parameters %}
+ {% set parameters = parameters|merge({name: element[attrib]}) %}
+ {% endfor %}
+
+ <form method="post" action="{{ path(routes.delete.path, parameters) }}" style="margin:0;display:inline" >
+ <input type="hidden" name="_method" value="DELETE" />
+ <button type="submit" class="btn btn-link" style="color:inherit;text-decoration:inherit;padding:0;margin:0;" {% if routes.delete.label is defined %}title="{{ routes.delete.label }}"{% endif %}>
+ <i class="icon-remove-sign"></i>
+ </button>
+ </form>
+{% endblock %}
@@ -1,46 +0,0 @@
-<tr>
-{% set element = element|toArray(options) %}
-{% for id, title in headers %}
- <td>
- {% if element[id] is defined %}{{ element[id] }}{% endif %}
- </td>
-{% endfor %}
-{% if routes|length > 0 %}
- <td>
-
- {% if routes.show is defined %}
- {% set parameters = [] %}
- {% for name, attrib in routes.show.parameters %}
- {% set parameters = parameters|merge({name: element[attrib]}) %}
- {% endfor %}
- <a href="{{ path(routes.show.path, parameters) }}" {% if routes.show.label is defined %}title="{{ routes.show.label }}"{% endif %}>
- <i class="icon-eye-open"></i>
- </a>
- {% endif %}
-
- {% if routes.edit is defined %}
- {% set parameters = [] %}
- {% for name, attrib in routes.edit.parameters %}
- {% set parameters = parameters|merge({name: element[attrib]}) %}
- {% endfor %}
- <a href="{{ path(routes.edit.path, parameters) }}" {% if routes.edit.label is defined %}title="{{ routes.edit.label }}"{% endif %}>
- <i class="icon-pencil"></i>
- </a>
- {% endif %}
-
- {% if routes.delete is defined %}
- {% set parameters = [] %}
- {% for name, attrib in routes.delete.parameters %}
- {% set parameters = parameters|merge({name: element[attrib]}) %}
- {% endfor %}
- <form method="post" action="{{ path(routes.delete.path, parameters) }}" style="margin:0;display:inline" >
- <input type="hidden" name="_method" value="DELETE" />
- <button type="submit" class="btn btn-link" style="color:inherit;text-decoration:inherit;padding:0;margin:0;" {% if routes.delete.label is defined %}title="{{ routes.delete.label }}"{% endif %}>
- <i class="icon-remove-sign"></i>
- </button>
- </form>
-
- {% endif %}
- </td>
-{% endif %}
-</tr>
@@ -30,18 +30,21 @@ public function getFilters()
public function getDataTableRender($elements, $options = array())
{
+ $options = array_merge(array('bootstrap' => "Default"), $options);
+
return $this
->container
->get('templating')
->render(
- 'KnpRadBundle:Twig:datatable.html.twig',
+ 'KnpRadBundle:Twig:Datatable/' . $options['bootstrap'] . '/datatable.html.twig',
array('elements' => $elements, 'options' => $options)
)
;
}
public function getDataTableRowRender($element, $headers, $options = array())
{
+ $options = array_merge(array('bootstrap' => "Default"), $options);
$routes = isset($options['routes'])
? $options['routes']
@@ -52,7 +55,7 @@ public function getDataTableRowRender($element, $headers, $options = array())
->container
->get('templating')
->render(
- 'KnpRadBundle:Twig:datatable_row.html.twig',
+ 'KnpRadBundle:Twig:Datatable/' . $options['bootstrap'] . '/datatable_row.html.twig',
array(
'element' => $element,
'headers' => $headers,

0 comments on commit b5113c4

Please sign in to comment.