[Resolved] DataTables & Smarty
[Resolved] DataTables & Smarty
david63
Posts: 7Questions: 0Answers: 0
This is possibly not a DataTables problem but more of a Smarty templating problem but I am hoping someone may be able to se what is going wrong (because I cannot and I have spent all day looking at it!)
Right then - I have been going along converting a standard PHP/Smarty set up to use dataTables and all has gone well until ...
I have the following within my Smarty template
[code]
$(document).ready(function() {
$('#example').dataTable( {
'bProcessing': true,
'bServerSide': true,
'bStateSave': false,
'bAutoWidth': true,
'bScrollCollapse': true,
'iDisplayLength': 10,
'sDom': 'W<"clear">ltipr',
'sPaginationType': 'full_numbers',
'sAjaxSource': './../test/data_test.php',
'oColumnFilterWidgets': {
'aiExclude': [0]
},
'aaSorting': [
[4, 'asc'],
[5, 'asc'],
[1, 'asc'],
],
'aoColumnDefs': [
{'aTargets': [0], 'bVisible': false},
{'aTargets': [4], 'bVisible': false},
{'aTargets': [5], 'bVisible': false},
],
});
});
[/code]
The problem that I have is with the
[code]'aoColumnDefs': [
{'aTargets': [0], 'bVisible': false},
{'aTargets': [4], 'bVisible': false},
{'aTargets': [5], 'bVisible': false},
],[/code]
part of the code. Everything else works fine but this bit of the code is generating a Smarty error (the crucial part being)
[quote]on line 31 ";{'aTargets': [0], 'bVisible': false}," - Unexpected ";: ", expected one of: ";}" , "" , ATTR'[/quote]
No matter what I do I cannot see what is causing the problem. I have tried:
- double/single quotes
- square/round/curly brackets
- surrounding various parts of the code with "" tags
- changing the order of the items
If I remove the "{}" from that part of the code then Smarty likes it but, obviously, DataTables does not.
If I remove that part of the code then everything works as it should but the columns are not hidden.
The same problem exists with "aoColumns".
I am using the latest version of DataTables (1.9.4) and the latest version of Smarty (3.1.12)
I cannot post a link as this is being run on my local machine.
Any advice, other than stop using Smarty, would be appreciated.
Right then - I have been going along converting a standard PHP/Smarty set up to use dataTables and all has gone well until ...
I have the following within my Smarty template
[code]
$(document).ready(function() {
$('#example').dataTable( {
'bProcessing': true,
'bServerSide': true,
'bStateSave': false,
'bAutoWidth': true,
'bScrollCollapse': true,
'iDisplayLength': 10,
'sDom': 'W<"clear">ltipr',
'sPaginationType': 'full_numbers',
'sAjaxSource': './../test/data_test.php',
'oColumnFilterWidgets': {
'aiExclude': [0]
},
'aaSorting': [
[4, 'asc'],
[5, 'asc'],
[1, 'asc'],
],
'aoColumnDefs': [
{'aTargets': [0], 'bVisible': false},
{'aTargets': [4], 'bVisible': false},
{'aTargets': [5], 'bVisible': false},
],
});
});
[/code]
The problem that I have is with the
[code]'aoColumnDefs': [
{'aTargets': [0], 'bVisible': false},
{'aTargets': [4], 'bVisible': false},
{'aTargets': [5], 'bVisible': false},
],[/code]
part of the code. Everything else works fine but this bit of the code is generating a Smarty error (the crucial part being)
[quote]on line 31 ";{'aTargets': [0], 'bVisible': false}," - Unexpected ";: ", expected one of: ";}" , "" , ATTR'[/quote]
No matter what I do I cannot see what is causing the problem. I have tried:
- double/single quotes
- square/round/curly brackets
- surrounding various parts of the code with "" tags
- changing the order of the items
If I remove the "{}" from that part of the code then Smarty likes it but, obviously, DataTables does not.
If I remove that part of the code then everything works as it should but the columns are not hidden.
The same problem exists with "aoColumns".
I am using the latest version of DataTables (1.9.4) and the latest version of Smarty (3.1.12)
I cannot post a link as this is being run on my local machine.
Any advice, other than stop using Smarty, would be appreciated.
This discussion has been closed.
Replies
Other thing I notice is that you have a trailing comma in each of your arrays - IE will reject that.
Allan
For anyone else encountering this problem I found that using [code]{ldelim} {rdelim}[/code] tags solved the problem.
Thanks also for the IE advice (just wish IE would use the standards!)
Right then onwards and upwards to find the next problem!!!