Choose columns to hide
Choose columns to hide
Hy friend.
I have a basic but difucult doubt.
I know that for exemple
<a class="toggle-vis" data-column = "12">HOLERITES</a>
Its works fine to a collumn, but i need do it with more collumns, to case of colspan.
<a class="toggle-vis" data-columns = "[12,13,14,15]">HOLERITES</a>
Detal:
I woud like of click at the button and only that collumn will be affected. The othhers not.
It is possible this way?
Thank that who can help-me.
I am Brasilian, than please, not worry for my english.
This question has an accepted answers - jump to answer
Answers
I'm not sure how this works. Are you using
column().visible()
API with this?Maybe you can use
columns().visible()
and pass in the array.Kevin
can you give-me a exemplo ?
My table is like:
**<tr>
<th colspan=5>Colls of One to five</th>
<th>Coll Six</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
....
<tr>
<td>Data One</td>
<td>Data Two</td>
<td>Data three</td>
<td>Data four</td>
<td>Data five</td>
<td>Data Six</td>
</tr>**
Here is an example:
http://live.datatables.net/tulozita/1/edit
Update the test case with what you are trying to do if you need more specific help.
Kevin
I did update the above comment
If you are having issues or questions please update the test case with what you are trying to do and provide information of how to recreate the issue.
Kevin
Ok, lets go.
<a>Togle Button</a>
My table is like:
**
<tr>
<th colspan=5>Colls of One to five</th>
<th>Coll Six</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
....
<tr>
<td>Data One</td>
<td>Data Two</td>
<td>Data three</td>
<td>Data four</td>
<td>Data five</td>
<td>Data Six</td>
</tr>
**
I would like hide and show the first collumn in a toggle button
Updated the example to show how to toggle. It uses
column().visible()
to get the current visibility to set the column visibility.http://live.datatables.net/tulozita/2/edit
Kevin
In the your example i dont found anything like:
1 th colspan=5
5 tds colspan=1
I need hde it all
As Kevin said, please update the test case to reflect your problem - if we can see it, we can debug it,
Colin
See this example about complex headers. You need to have one header row that contains a
th
tag for each column. Having one-thead
row with-tg colspan
is not supported by Datatables.Do you mean the whole table? Just use jQuery to hide the table. Inspect your page to find the `-tag div1 the Datatable is in to hide all the elements.
Please be specific about what you want to hide. Each post the requirement changes from hiding multiple columns, to toggling one column to hiding it all.
Kevin
I need hde it all, it means all collumns that follow the colspn collum
About this example:
https://datatables.net/examples/basic_init/complex_header.html
My table is similar.
But i need hide and show the HR Information collum with colspan
As mentioned before use
columns().visible()
to hide or show multiple columns. Pass intocolumns()
acolumn-selector
to choose the columns to hide. Use an array of column indexes or maybe classname as an example. My example above uses an array of column indexes.Pass
true
orfalse
into thecolumns().visible()
to toggle the visibility. You can use the visibility state of one of the columns, assuming they are all toggled at the same time. Otherwise you can loop through each withcolumns().every()
to toggle each one individually.See this example with colspan and toggling the HR columns:
http://live.datatables.net/tulozita/4/edit
Kevin
Okay guys, thanks.
The problem is removing and inserting colspan on hide and show columns.
A blank space is getting between the two columns when I remove the middle column between them
But okay, looks like I'll have to learn to live with it. Hahaha
Thanks for everything!
Do you see that problem in the test case? If you do please provide the steps to show the issue.
I updated the test case to remove the middle column of the Contact colspan:
http://live.datatables.net/tulozita/6/edit
We can take a look if you provide a test case that shows the problem.
Kevin
I got it
<a class="toggle-vis" data-columns="1">Admissão</a>
<a class="toggle-vis" data-columns="2,3,4,5,6">Filial</a>
Please provide a running example of the issue. Code snippets won't help use debug.
Kevin
https://jsfiddle.net/carcleo1999/8xjLz1c6/15/
See you it.
It was what i did need
Tank you!
I did it!