Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jQuery Datables - hiding column is NOT working

Posted on 2016-10-12
3
Medium Priority
?
428 Views
Last Modified: 2016-11-01
I am trying to hide a column in my Datatables. but it is not working.    

I was trying to use this function - "table.fnSetColumnVis( 12, false);"


$(document).ready(function() 
{

$('table[summary="2CIA4_Rules "]').attr('id','ruletable');
$('#ruletable thead').remove();
$('table[summary="2CIA4_Rules "]').find('tr').each(function(){
         var trow = $(this);
         trow.prepend('<td class="rowbutton"><button class="ui-button">User List</button></td>');
     });
$('#ruletable').prepend('<thead><tr class="ruleheader"><td>List</td><td>Rule</td><td>Owner</td><td>Audience</td><td>Curriculum</td><td>Target Area</td><td>Leader</td><td>Leader_WWID</td><td>MRC</td><td>Legal</td><td>JobFunction</td><td>SubFunction</td><td>Exclusions</td><td>Year 4 Notes</td><td>Comments</td><td>ChangeNotes</td></tr></thead');

var mSortingString = [];
var disableSortingColumn = 0; 
mSortingString.push({ "bSortable": false, "aTargets": [disableSortingColumn] });    

var table = $( ".ms-listviewtable" ).DataTable( {
		dom: 'Tf<"clear">rtip',
		"paging": false,
		"sScrollY": "400px",
		"sScrollX": true,
		"aoColumnDefs": mSortingString
    });   

table.fnSetColumnVis( 12, false);

});

Open in new window

0
Comment
Question by:aehrenwo
  • 2
2 Comments
 
LVL 44

Accepted Solution

by:
zephyr_hex (Megan) earned 2000 total points (awarded by participants)
ID: 41842112
Since DataTables 1.10, you can use columns().visible()
Here is the syntax:

table.columns(12).visible(false);

Open in new window


If you want to hide multiple columns:

table.columns([11,12]).visible(false);

Open in new window


Here is a Fiddle Demo
0
 
LVL 44

Expert Comment

by:zephyr_hex (Megan)
ID: 41860609
Were you able to resolve your problem?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question