Hi Leute,
alles klar ? Naja ich hoffe ihr könnt mir helfen habe ein ziemliches Problem Datatables in eine Spring Applikation einzubinden. Ich konnte bis jetzt auch noch keine aussagekräftige Dokumentation dazu finden.
Datatables link: DataTables | Table plug-in for jQuery
Ich möchte Datatables serverseitig betreiben habe aber überhaupt keine Ahnung wie der Controller und die Jsppage aussehen sollten.
Mein Controller bis jetzt:
[Java]
@RequestMapping(value = "searchdb")
public @ResponseBody String searchIntern(@ModelAttribute("objekt")
@RequestParam int iDisplayStart,
@RequestParam int iDisplayLength,
@RequestParam int iColumns,
@RequestParam String sSearch,
@RequestParam boolean bEscapeRegex,
@RequestParam boolean bSortable_,
@RequestParam boolean bSearchable_,
@RequestParam String sSearch_,
@RequestParam boolean bEscapeRegex_,
@RequestParam int iSortingCols,
@RequestParam int iSortCol_,
@RequestParam String sSortDir_,
@RequestParam String sEcho,
Presseclipping searchPresseclipping,
HttpServletRequest request, Model model) {
[/code]
die Jsp Seite sieht so aus:
javascript wie folgt:
vielleicht hat jemand soetwas schon einmal integriert und kann mir tipps vl sogar code geben oder eine Doku wäre super.
Wenn ihr noch irgendwelche Informationen benötigt einfach Bescheid geben.
lg
alles klar ? Naja ich hoffe ihr könnt mir helfen habe ein ziemliches Problem Datatables in eine Spring Applikation einzubinden. Ich konnte bis jetzt auch noch keine aussagekräftige Dokumentation dazu finden.
Datatables link: DataTables | Table plug-in for jQuery
Ich möchte Datatables serverseitig betreiben habe aber überhaupt keine Ahnung wie der Controller und die Jsppage aussehen sollten.
Mein Controller bis jetzt:
[Java]
@RequestMapping(value = "searchdb")
public @ResponseBody String searchIntern(@ModelAttribute("objekt")
@RequestParam int iDisplayStart,
@RequestParam int iDisplayLength,
@RequestParam int iColumns,
@RequestParam String sSearch,
@RequestParam boolean bEscapeRegex,
@RequestParam boolean bSortable_,
@RequestParam boolean bSearchable_,
@RequestParam String sSearch_,
@RequestParam boolean bEscapeRegex_,
@RequestParam int iSortingCols,
@RequestParam int iSortCol_,
@RequestParam String sSortDir_,
@RequestParam String sEcho,
Presseclipping searchPresseclipping,
HttpServletRequest request, Model model) {
[/code]
die Jsp Seite sieht so aus:
Code:
<div class="table-responsive">
<table id="data_table"
class="dataTable table table-striped table-bordered" cellspacing="0"
width="100%">
<thead>
<tr>
<th>Titel</th>
<th>Medium</th>
<th>Datum</th>
<th>Aktion</th>
</tr>
</thead>
<tbody>
<c:forEach var="treffer" items="${objekt}">
<tr>
<td>${treffer.wert}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
javascript wie folgt:
Code:
<script> var contextPath = "<%= request.getContextPath() %>"; </script>
<script>
$(document).ready(function() {
$('#data_table').dataTable( {
columnDefs: [
{ type: 'de_datetime', targets: 0 },
{ type: 'de_date', targets: 2 }
],
"bProcessing": true,
"bServerSide": true,
"iDisplayLength" : 10,
"iDisplayStart": 0,
"sEcho":1,
"sAjaxSource": contextPath + "/searchdb.do",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
</script>
vielleicht hat jemand soetwas schon einmal integriert und kann mir tipps vl sogar code geben oder eine Doku wäre super.
Wenn ihr noch irgendwelche Informationen benötigt einfach Bescheid geben.
lg
Zuletzt bearbeitet: