@ -1,46 +1,50 @@
<!-- datatables_multifield -->
<script type="text/javascript">
var checked_fields = {} ;
var checked_fields = [] ;
$(document).ready(function() {
[%IF value%]
JSON.parse('[% value %]').map( function (val) {
checked_fields[val] = 1 ;
checked_fields.push(val) ;
});
[%END%]
$('#[% table_id %] tr td input[type="checkbox"]').live( "click", function() {
var my_id = $(this).parents("tr").find("td:first").text();
var indexOfId = checked_fields.indexOf(my_id)
if($(this).attr("checked") == "checked") {
checked_fields[my_id] = 1;
if(indexOfId < 0){
checked_fields.push(my_id);
}
} else {
delete checked_fields[my_id];
if( indexOfId >= 0){
checked_fields.splice(indexOfId,1);
}
}
$("#[% hidden_id %]").val( JSON.stringify(Object.keys(checked_fields)) );
$("#[% hidden_id %]").val( JSON.stringify(checked_fields) );
});
$('#[% table_id %]')
.dataTable( {
$('#[% table_id %]')
.dataTable( {
"sDom": "<'row-fluid'<'pull-left'r><'pull-right'f>>t<'row-fluid'<'pull-left'i><'pull-right'p>>",
"bProcessing": true,
"bServerSide": true,
"bPaginate": true,
"bProcessing": true,
"bServerSide": true,
"bPaginate": true,
"sPaginationType": "bootstrap",
"bLengthChange": false,
"bSort": true ,
"bInfo": true,
"iDisplayLength": 4,
"bLengthChange": false,
"bSort": [%IF no_ordering; 'false'; ELSE; 'true'; END%] ,
"bInfo": true,
"iDisplayLength": 4,
'iShowPages': 5,
"oLanguage": {
"sUrl": "/js/i18n/[% language_file %]"
},
"sAjaxSource": "[% ajax_src %]",
"aoColumns": [
"sAjaxSource": "[% ajax_src %]",
"aoColumns": [
[% FOREACH f IN table_fields -%]
{
{
"mData": "[% f %]",
"mRender": function ( data, type, full ) {
if(data == null)
@ -49,16 +53,16 @@ $(document).ready(function() {
}
},
[% END -%]
{ "mRender": function ( data, type, full ) {
{ "mRender": function ( data, type, full ) {
return '<input type="checkbox" value="' + full.id + '"/>';
},
"mData": null,
"bSortable": false
}
],
],
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
nRow.className = "sw_action_row";
if($(nRow).find("td:first").text() in checked_fields )
if(checked_fields.indexOf($(nRow).find("td:first").text()) >= 0 )
{
$(nRow).find("td input[type='checkbox']").attr("checked", "checked");
}
@ -67,7 +71,7 @@ $(document).ready(function() {
"fnServerParams": function ( aoData ) {
//aoData.push( {"name":"iIdOnTop","value":"[% value %]"} );
},
} );
} );
} );
</script>