Montiyago
Montiyago

Reputation: 647

How to hide the column-toggle button from the table?

I want to hide the column-toggle button or column chooser button from the table appears above the table. I am using the jQuery Mobile ver. 1.3.2.

i'm using this:

<table data-role="table" id="table-column-toggle" data-mode="columntoggle" class="ui-responsive table-stroke">
 <thead class="pearlHeading">
  <tr>
   <th data-priority="1">S.No.</th>
   <th >Name of the Programme</th>
   <th data-priority="2">Campus</th>
  </tr>
 </thead>
 <tbody>
 </tbody>
</table>

I remove the

data-role="table" id="table-column-toggle" data-mode="columntoggle"

but its not working properly

Upvotes: 9

Views: 11412

Answers (4)

Himanshu Dhiraj Mishra
Himanshu Dhiraj Mishra

Reputation: 1079

Mine more professional, Use :

data-mode="columntoggle:none"

Working Example:

<!DOCTYPE html>
<html>

<head>
  <title>jQM Complex Demo</title>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi" />
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
  <!--<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>-->
  <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>

<body>
  <div data-role="page" id="index">
    <div data-theme="b" data-role="header">
      <h1>Index page</h1>
    </div>

    <div data-role="content">
      <table data-role="table" id="table-column-toggle" data-mode="columntoggle:none" class="ui-responsive table-stroke">
        <thead class="pearlHeading">
          <tr>
            <th data-priority="1">S.No.</th>
            <th>Name of the Programme</th>
            <th data-priority="2">Campus</th>
          </tr>
        </thead>
        <tbody>
        </tbody>
      </table>
    </div>
  </div>
</body>

</html>

http://jsfiddle.net/Lsoesxtv/1/

Upvotes: 13

Saulo
Saulo

Reputation: 29

I've found a simpler solution

1) Declare the following CSS class

.ui-btn-z {
    display: none !important;
}

2) Set this attribute on the table tag

data-column-btn-theme="z"

That should be it :)

Upvotes: 2

Edgardo Amaya
Edgardo Amaya

Reputation: 21

I use the response of "Gajotres" but ...

applies to all "buttons table toggle" and you could not "choose" which apply, if you edit .js it a bit :

jquery.mobile - 1.3.2.min.js (gzip) line 6 column 11429

d=a(k.columnBtnText===""?"":"<a href='#"+m+"' class='"+k.classes.columnBtn+"' data-"+l+"rel='popup' data-"+l+"mini='true'>"+k.columnBtnText+"</a>")

jquery.mobile - 1.3.2.js line 10872

if ( event ! == " refresh" ) {
self.element.addClass ( o.classes.columnToggleTable ) ;
if ( o.columnBtnText === "") {
$MenuButton = $(""),
else {
$menuButton = $("<a href='#" + id + "' class='" + o.classes.columnBtn + "' data-" + ns         + "rel='popup' data-" + ns + "mini='true'>" + o.columnBtnText + "</a>" ),
}
$ popup = $ (" < div data- " + ns + " role = ' popup' data- " + ns + " role = ' fieldcontain ' class = '" + o.classes.popup + " ' id = ' " + id + "' > < / div >") ,
$ menu = $ (" + ns + <fieldset data-" "role='controlgroup'> < / fieldset >") ;

the code does ? , if the "text" button is blank data-column-btn-text=""... does not show the button and thus can decide which to display and which to hide

then only a little editing . js no longer need the css and you can choose where you hide the button

Upvotes: 0

Gajotres
Gajotres

Reputation: 57309

Working example: http://jsfiddle.net/Gajotres/pdYre/

CSS:

.ui-table-columntoggle-btn {
    display: none !important;
}

Upvotes: 11

Related Questions