Solved

jQuery Datables - hiding column is NOT working

Posted on 2016-10-12
3
85 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
zephyr_hex (Megan) earned 500 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 43

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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…

749 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