I don't see columns during rendering datatables - serverside,processing
I don't see columns during rendering datatables - serverside,processing

I'm done server-side programming.
"processing": true,
"serverSide": true,
This is great for me.
Right now when I render tables using <th>, I don't see any columns <th></th>, only those declared in the code javascript.
array( 'db' => 'as_name', 'dt' => 2 ),
array( 'db' => 'as_cat_name', 'dt' => 3 ),
array( 'db' => 'as_producent', 'dt' => 4 ),
I think datatables overwrites my settings.
How to create mix colums in datatables ?
<script>
$(document).ready(function() {
$('#xyz_akcesoria_dTable').DataTable( {
//"responsive": true,
"processing": true,
"serverSide": true,
"ajax": "xyz.php",
//2,3,4 - visible
"columnDefs": [
{
"targets": [ 0 ],
"visible": false,
"searchable": false
},
{
"targets": [ 1 ],
"visible": false,
"searchable": false
},
{
"targets": [ 5 ],
"visible": false,
"searchable": false
},
{
"targets": [ 6 ],
"visible": false,
"searchable": false
},
{
"targets": [ 7 ],
"visible": false,
"searchable": false
},
{
"targets": [ 8 ],
"visible": false,
"searchable": false
}
]
} );
} );
</script>
<table id="xyz_akces_dTable" class="table table-striped table-hover">
<thead>
<th></th> <!-- number - I DON'T SEE -->
<th>name</th> <!-- array( 'db' => 'as_name', 'dt' => 2 ), -->
<th>type</th> <!-- array( 'db' => 'as_cat_name', 'dt' => 3 ), -->
<th>producent</th> <!-- array( 'db' => 'as_producent', 'dt' => 4 ), -->
<th>amount</th> <!-- amount - I DON'T SEE -->
<th></th> <!-- other data - I DON'T SEE button -->
</thead>
<tbody>
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
This discussion has been closed.
Replies
You have
"visible": false,
set for columns 0, 1, 5, 6, 7, 8. If you want them visible either remove the line or set it totrue
. Also it looks like you have 6 columns defined in your HTML but yourcolumnDefs
is configured for 9 columns. The need to match. You are probably getting Javascript errors that you can see in the browser's console.Additionally if you are doing the same config options with multiple columns you can set
columnDefs.targets
to an array, like this:Kevin
I don't know if you understand my issue.
Is possible show mix tables, HTML and data from database via datatables ?
<thead>
<th>A</th> <!-- I don't want to see data from database -->
<th>name</th> <!-- OK array( 'db' => 'as_name', 'dt' => 2 ), -->
<th>type</th> <!-- OK array( 'db' => 'as_cat_name', 'dt' => 3 ), -->
<th>producent</th> <!-- OK array( 'db' => 'as_producent', 'dt' => 4 ), -->
<th>E</th> <!-- I don't want to see data from database -->
<th>F</th> <!-- I don't want to see data from database -->
</thead>
During rendering 2 second is OK
after 2 seconds the tables are filled with data from datatables
It's NO OK
I would like A,E,F columns rendering without data from JS datatables
If I understand correctly you have an HTML based table. Then when using server side processing the HTML table is removed and replaced by the server side processing data. Is this your question?
You can see this same behavior in this test case:
http://live.datatables.net/nujosona/1/edit
If you are using
ajax
then Datatables will overwrite the DOM based table. You could have a DOM based table and use jQuery ajax() to fetch the data followed byrows.add()
to add the server based data to the DOM based table. However, doing this would remove the capability of using Datatables server side processing.Does this answer your questions?
Kevin
I'm sad
I need use server site processing.
I have to change my approach to code - change a code.
Thank you for help.