You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-panel/share/templates/helpers/datatables_field.tt

83 lines
2.7 KiB

<script type="text/javascript">
$(document).ready(function() {
$('#[% table_id %] tr td input[type="checkbox"]').live( "click", function() {
$("#[% hidden_id %]").val( $(this).parents("tr")
.find("td:first").text() );
if($(this).attr("checked") == "checked") {
$(this).parents("tr").siblings().find("td input[type='checkbox']").attr("checked", false);
}
});
$('#[% 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,
"sPaginationType": "bootstrap",
"bLengthChange": false,
"bSort": true,
"bInfo": true,
"iDisplayLength": 4,
'iShowPages': 5,
"sAjaxSource": "[% ajax_src %]",
"aoColumns": [
[% FOREACH f IN table_fields -%]
{ "mData": "[% f %]" },
[% END -%]
{ "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() == $("#[% hidden_id %]").val())
{
$(nRow).find("td input[type='checkbox']").attr("checked", "checked");
}
return nRow;
},
"fnServerParams": function ( aoData ) {
aoData.push( {"name":"iIdOnTop","value":"[% value %]"} );
},
} );
} );
</script>
<div class="control-group [% IF errors.size %]error[% END %]">
<label class="control-label" for="[% table_id %]">[% label %]</label>
<div class="controls">
<input type="hidden" name="[% field_name %]" value="[% value %]" id="[% hidden_id %]"/>
<table class="table table-bordered table-striped table-highlight table-hover" id="[% table_id %]">
<thead>
<tr>
[% FOREACH t IN table_titles %]
<th>[% t %]</th>
[% END %]
<th class="span"></th>
</tr>
</thead>
<tbody>
<tr class="sw_action_row">
<td>Loading</td>
</tr>
</tbody>
</table>
[% IF errors.size -%]
<span class="help-inline">
[% errors.join('<br/>') %]
</span>
[% END -%]
</div>
</div>
[% # vim: set tabstop=4 syntax=html expandtab: -%]