Datatable with exlusion on the search filter with a certain class
I have a HTML table, in fact I have more tables acrross my site.
So I created a class called datatable, which covers most of my generic table needs.
For exports, like PDF and Excel, I managed to exclude the column with the class ignore.
I want to exclude the column with the ignore class dynamically.
I want to be abble to set more columns with the ignore class and avoid the filter to go trough these columns.
It's not necesery that there will be a button or a elements, so please avoid suggesting that I just exclude these.
In a specific case, I have a name Edit Valvasor, and I want the filter to find the row with when I type "Edit" in the filter and ignore the columns with Edit buttons.
Example can be found here: http://jsfiddle.net/t1h9ugqa/
Javascript:
$(document).ready(function() {
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'csv',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'excel',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'pdf',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'print',
customize: function(win) {
$(win.document.body).addClass('white-bg');
$(win.document.body).css('font-size', '10px');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
HTML:
<table class="datatable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Sum</th>
<th class="ignore"></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Edit Valvasor</td>
<td>1034</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>2</td>
<td>Samuel Grixis</td>
<td>655</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>3</td>
<td>Martin Kempinsky</td>
<td>153</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
</tbody>
</table>
jquery datatables
add a comment |
I have a HTML table, in fact I have more tables acrross my site.
So I created a class called datatable, which covers most of my generic table needs.
For exports, like PDF and Excel, I managed to exclude the column with the class ignore.
I want to exclude the column with the ignore class dynamically.
I want to be abble to set more columns with the ignore class and avoid the filter to go trough these columns.
It's not necesery that there will be a button or a elements, so please avoid suggesting that I just exclude these.
In a specific case, I have a name Edit Valvasor, and I want the filter to find the row with when I type "Edit" in the filter and ignore the columns with Edit buttons.
Example can be found here: http://jsfiddle.net/t1h9ugqa/
Javascript:
$(document).ready(function() {
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'csv',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'excel',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'pdf',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'print',
customize: function(win) {
$(win.document.body).addClass('white-bg');
$(win.document.body).css('font-size', '10px');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
HTML:
<table class="datatable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Sum</th>
<th class="ignore"></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Edit Valvasor</td>
<td>1034</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>2</td>
<td>Samuel Grixis</td>
<td>655</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>3</td>
<td>Martin Kempinsky</td>
<td>153</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
</tbody>
</table>
jquery datatables
add a comment |
I have a HTML table, in fact I have more tables acrross my site.
So I created a class called datatable, which covers most of my generic table needs.
For exports, like PDF and Excel, I managed to exclude the column with the class ignore.
I want to exclude the column with the ignore class dynamically.
I want to be abble to set more columns with the ignore class and avoid the filter to go trough these columns.
It's not necesery that there will be a button or a elements, so please avoid suggesting that I just exclude these.
In a specific case, I have a name Edit Valvasor, and I want the filter to find the row with when I type "Edit" in the filter and ignore the columns with Edit buttons.
Example can be found here: http://jsfiddle.net/t1h9ugqa/
Javascript:
$(document).ready(function() {
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'csv',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'excel',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'pdf',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'print',
customize: function(win) {
$(win.document.body).addClass('white-bg');
$(win.document.body).css('font-size', '10px');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
HTML:
<table class="datatable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Sum</th>
<th class="ignore"></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Edit Valvasor</td>
<td>1034</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>2</td>
<td>Samuel Grixis</td>
<td>655</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>3</td>
<td>Martin Kempinsky</td>
<td>153</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
</tbody>
</table>
jquery datatables
I have a HTML table, in fact I have more tables acrross my site.
So I created a class called datatable, which covers most of my generic table needs.
For exports, like PDF and Excel, I managed to exclude the column with the class ignore.
I want to exclude the column with the ignore class dynamically.
I want to be abble to set more columns with the ignore class and avoid the filter to go trough these columns.
It's not necesery that there will be a button or a elements, so please avoid suggesting that I just exclude these.
In a specific case, I have a name Edit Valvasor, and I want the filter to find the row with when I type "Edit" in the filter and ignore the columns with Edit buttons.
Example can be found here: http://jsfiddle.net/t1h9ugqa/
Javascript:
$(document).ready(function() {
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'csv',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'excel',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'pdf',
exportOptions: {
columns: ':not(.ignore)',
}
},
{
extend: 'print',
customize: function(win) {
$(win.document.body).addClass('white-bg');
$(win.document.body).css('font-size', '10px');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
HTML:
<table class="datatable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Sum</th>
<th class="ignore"></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Edit Valvasor</td>
<td>1034</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>2</td>
<td>Samuel Grixis</td>
<td>655</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
<tr>
<td>3</td>
<td>Martin Kempinsky</td>
<td>153</td>
<td>
<a class="btn btn-primary" href="#">Edit</a>
</td>
</tr>
</tbody>
</table>
jquery datatables
jquery datatables
asked Nov 26 '18 at 9:40
RumplinRumplin
2,2431637
2,2431637
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
you can add:
columnDefs: [
{ searchable: false, targets: 3 }
],
the code in the example is like: //target is the number of column
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],columnDefs: [
{ searchable: false, targets: 3 }
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
You might read my post again. I don't want to set datatables options in javascript. I want to set a class on a table header
– Rumplin
Nov 27 '18 at 10:34
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53478300%2fdatatable-with-exlusion-on-the-search-filter-with-a-certain-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can add:
columnDefs: [
{ searchable: false, targets: 3 }
],
the code in the example is like: //target is the number of column
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],columnDefs: [
{ searchable: false, targets: 3 }
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
You might read my post again. I don't want to set datatables options in javascript. I want to set a class on a table header
– Rumplin
Nov 27 '18 at 10:34
add a comment |
you can add:
columnDefs: [
{ searchable: false, targets: 3 }
],
the code in the example is like: //target is the number of column
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],columnDefs: [
{ searchable: false, targets: 3 }
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
You might read my post again. I don't want to set datatables options in javascript. I want to set a class on a table header
– Rumplin
Nov 27 '18 at 10:34
add a comment |
you can add:
columnDefs: [
{ searchable: false, targets: 3 }
],
the code in the example is like: //target is the number of column
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],columnDefs: [
{ searchable: false, targets: 3 }
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
you can add:
columnDefs: [
{ searchable: false, targets: 3 }
],
the code in the example is like: //target is the number of column
$('.datatable').DataTable({
lengthMenu: [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],columnDefs: [
{ searchable: false, targets: 3 }
],
pageLength: 25,
dom: '<"html5buttons"B>lTfgitp',
aaSorting: ,
buttons: [{
extend: 'copy',
exportOptions: {
columns: ':not(.ignore)',
}
answered Nov 26 '18 at 16:38
Wilmer Ofelio Alama SeminarioWilmer Ofelio Alama Seminario
6916
6916
You might read my post again. I don't want to set datatables options in javascript. I want to set a class on a table header
– Rumplin
Nov 27 '18 at 10:34
add a comment |
You might read my post again. I don't want to set datatables options in javascript. I want to set a class on a table header
– Rumplin
Nov 27 '18 at 10:34
You might read my post again. I don't want to set datatables options in javascript. I want to set a class on a table header
– Rumplin
Nov 27 '18 at 10:34
You might read my post again. I don't want to set datatables options in javascript. I want to set a class on a table header
– Rumplin
Nov 27 '18 at 10:34
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53478300%2fdatatable-with-exlusion-on-the-search-filter-with-a-certain-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown