how to change the default number of records to display and instead of number use a head column field
how to change the default number of records to display and instead of number use a head column field
gnux8
Posts: 30Questions: 4Answers: 0
Good Afternoon,
reading this:
https://datatables.net/forums/discussion/162/how-to-change-the-default-number-of-records-to-display
I would like to know if is possible instead of number use a column field for example using this:
https://datatables.net/examples/basic_init/language.html
I would like to have "OFFICE" as select input and have a modified table with all the record that are matching the office field.
Best Regards,
Andrea
This discussion has been closed.
Answers
Hi @gnux8 ,
You would be able to use the page length control, as it's not intended for that purpose - but you could add your own control that filters the table on the string in the menu.
Cheers,
Colin
Note, thread duplicated, see here https://datatables.net/forums/discussion/55586/how-to-change-the-default-number-of-records-to-display-and-instead-of-number-use-a-head-column-field#latest . Please raise just once.
Correction to Colin's post:
"You would NOT be able to use the page length control...."
pffft what's a missing word here or there
Thank you, i will try to have a look the post sent and i'll come back in case of need thank you
Yes, we have right I've duplicated but i didn't found a way to delete one, for left only one post ...
Could you kindly tell me how I can make a custom filter for a table ? sorry but i didn't know from where start. Thanks you
This dropdown here determines which column the search box will affect. You could have a similar dropdown that
onchange
would initiate a search.Looking your example I've understood that with "Search Column" your and selecting which field do you want search for example "Position" and then in "Search" put the term of the research for example "System" .
what i would like to obtain is:
and when is selected filter the table,
is possible that ?
Br
Andrea
Maybe you can adapt this example to fit your needs.
https://datatables.net/examples/api/multi_filter_select.html
Kevin
I think is too difficult to do :-(
Good Morning, I've well implemented the filter :-) thansk for the support ... now i would like to add a sum into the footer ...
https://datatables.net/examples/advanced_init/footer_callback.html
How i can mix the features ?
i think that the problem is related how to implement the js
so actually i have this in my js
and i would add also this:
How i can combine in only one ?
Thanks
Andrea
EDIT: Updated to use Markdown Code formatting
You simply move the footerCallback into the first Datatable initialization. Datatables expects all the options to be in one initialization call. Just make sure you have a comma separating the options otherwise you will get a syntax errror.
Kevin
do you mean add a comma at the end the first initialization and the second code ? could you kindly past the example ? thanks :-)
Something like this:
Kevin
Thanks it works that means that if you want then add another function just do like the example that you did it :-) i would add also this example :-)
https://datatables.net/extensions/buttons/examples/initialisation/export.html
Thanks 1000000
Andrea
Yes, they all go into one Datatables initialization
Kevin
Thanks, the part related the js it's ok the point is that im not able to extract the part realted to html in the sense that im not able to find the button definition
could you kindly help ?
thanks :-)110000101010101010101
Not sure what that means. Without seeing what you are doing and knowing excatly what is happening its hard to help. Please post a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Ok, I've the button on the page and loaded all the module listed into the example ... but no action behind the press button where i can investigate ? thanks Andrea
in attachement the file
Looks like you are loading jQuery.js and Datatables.js twice; once at the top and once at the bottom. They should only be loaded once.
I don't see where you are loading the CSS files for the buttons.
My suggestion would be to build a simple test case using one of the options I linked to above. Start simple with a basic Bootstrap based Datatable then add buttons and other features. This will make it easier to help you.
Kevin
Thanks you most probably I've forget the css ... I've downloaded but not reference ... i'll double check and i'll let you know :-) thanks you
im trying as you suggested also i've download entire example ...
Ciao in attachment I've modified the tables.html and you can find the datables ... Now the stilesheet has been apllied to the button but still to have no action ... maybe could be the datatables-demo.js the issues ?
You are still loading jquery.js and datatables.js twice. You have them loading at the top of the tables.html and at the bottom.
Kevin
I've created a simple example also !
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
initComplete: function () {
this.api().columns().every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
} );
</html>
Is this still the problem?
You have this
div
created:I suspect these are the buttons you are referring to. You don't need to create this. Datatables will do it for you with the
B
parameter indom: 'Bfrtip',
. If its not creating the buttons for you then there is still a problem. At this point it would be hard to help debug without actually seeing it. Can you post a link to your page or a test case so we can help?https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Take a look at the browser's console for errors.
Kevin
Sorry I was testing the test locally what a stupid guys without loading the file on server :-) it's friday ... now the test example is working i will try to be focus on the others... i'll come back soon thnk
Ok, with your advise I've fixed :-) the errrors were related to double entry of datables and also I've the button after the table in order to have displayed only one times ... instead twice :-) thanks again for your useful advise :-)