Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have a requirement for Hiding column of the data table and unhide it with a button click.
The button name is Hide Column.
What is required is once I click on Hide Column the text of the data table button should change to Show Column and vice versa.

Is it possible.

Please guide.
Posted

You can use a Flag. Let say the initial status is 0 i.e Hide Columns. When you click the button set flag status to 1 and text to Show Columns.
 
Share this answer
 
JavaScript
$("#button").click(function(){$("table tr td:nth-child(no)").hide();});


Where no is the column position of you table.
 
Share this answer
 
$(nButton).text($(nButton).text() =="Hide Columns" ? "Show Columns" : "Hide Columns");

The button text could be controlled by nButton in data table. It solved my issue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900