Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column toggle widget #1745

Closed
ghost opened this issue Jan 22, 2019 · 10 comments
Closed

Column toggle widget #1745

ghost opened this issue Jan 22, 2019 · 10 comments
Assignees
Labels
Enhancement Possible small update to an existing feature

Comments

@ghost
Copy link

ghost commented Jan 22, 2019

Hi Oli great job with the Tabulator project.
I would like to find out if you will be working on any column toggle widget for tabulator in future?

I have been using w2ui for a while something like this looks pretty good:
wi

I know we can hide columns in Tabulator but It'll look nice to have it integrated in say the filters

for example.

wi

At the moment I'm busy making my own for Tabulator, It'll be nice to have a more authentic looking one though.

@Rodbjartson
Copy link

Perhaps you could make a pull request once it is working? That way you can contribute to the project!:)

@olifolkerd olifolkerd self-assigned this Jan 28, 2019
@olifolkerd olifolkerd added Documentation An issue with the tabulator.info documentation Website Issue or update tabulator.info website labels Jan 28, 2019
@olifolkerd
Copy link
Owner

Hey @1MALKAVIAN

Thanks for getting in touch,

Thanks for your kind words, it is always great to hear that people are enjoying using Tabulator.

Sorry for the delayed response, I have been busy working on the 4.2 release for next week

Tabulator only maintains elements within the table itself, all those inputs and buttons above the table are not part of Tabulator they just call functions on the table.

I have no intention of developing any features that sit outside of the table element itself as that is outside the scope of the project.

That being said i would be happy to update one of the examples to include a column toggle list if you think that would be of use to you.

Cheers

Oli :)

@ghost
Copy link
Author

ghost commented Jan 29, 2019

Hey @1MALKAVIAN

Thanks for getting in touch,

Thanks for your kind words, it is always great to hear that people are enjoying using Tabulator.

Sorry for the delayed response, I have been busy working on the 4.2 release for next week

Tabulator only maintains elements within the table itself, all those inputs and buttons above the table are not part of Tabulator they just call functions on the table.

I have no intention of developing any features that sit outside of the table element itself as that is outside the scope of the project.

That being said i would be happy to update one of the examples to include a column toggle list if you think that would be of use to you.

Cheers

Oli :)

Thanks Oli, that would be quite helpful.
If I come up with anything good in future I'll definitely make a pull request.

@ghost
Copy link
Author

ghost commented Feb 6, 2019

Hi again, I managed to put some time into the widget. It's not looking good yet but it does what I want in the simplest form.

cc

I want to improve the code. At the moment each checkbox calls a function which contains table.toggleColumn(""); I would like to automatically read the columns names from the table. I thought about using the table.getColumns() function but I'm not sure how to get the objects into variables so I can use them. This may not be a good method though... I'm open to suggestions .

Perhaps there is a widget plug in which can work with tabulator? I was not able to find any though.

Here's my code:

HTML:
Just a hover dropdown example from w3schools modified a bit. LINK

<div class="dropdown">
  <button onclick="myFunction()" class="dropbtn">
    <span class=""></span>
  </button>

  <div id="myDropdown" class="dropdown-content">
    <ul class="items">
    <li><input  type="checkbox" onclick="myFunction1()">ID Toggle</a></li>
    <li><input  type="checkbox" onclick="myFunction2()">Vehicle Toggle</a></li>
    <li><input  type="checkbox" onclick="myFunction3()">Date Serviced From Toggle</a></li>
    <li><input  type="checkbox" onclick="myFunction4()">Date Serviced To Toggle</a></li>
</ul>
  </div>
</div>

CSS:
Dropdown styling.

.dropbtn {
  background-color: rgb(187, 202, 187);
  color: white;
  padding: 16px;
  font-size: 9px;
  border: none;
  cursor: pointer;
  background: url(http://www.stackoverflow.com/favicon.ico) 50% no-repeat #eee;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  
  display: none;
  font-size: 11px;
  position: absolute;
  right: 80;
  border: 1px solid black;
  outline-style: outset;
  outline-color: lightblue;
  background-color: #c0b9b9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown:hover .dropbtn {
  background-color: lightblue;
}

JS:
Js functions in my tables script.

//column toggle functions
function myFunction1() {
  table.toggleColumn("id");
}

function myFunction2() {
    table.toggleColumn("Assigned To");
//var cols = table.getColumns() //get array of column components
//console.log(JSON.stringify(cols))
}

function myFunction3() {
  table.toggleColumn("Name");
}
function myFunction4() {
  table.toggleColumn("Surname");
}

ezgif com-video-to-gif

So I want to remove the redundant JS functions and getcolumns() to automatically get the columns. Let me know if you need any more info.

Thanks

@olifolkerd olifolkerd added Enhancement Possible small update to an existing feature and removed Documentation An issue with the tabulator.info documentation Website Issue or update tabulator.info website labels Jul 21, 2019
@NaveenSelvaraj
Copy link

NaveenSelvaraj commented May 18, 2020

Hi again, I managed to put some time into the widget. It's not looking good yet but it does what I want in the simplest form.

cc

I want to improve the code. At the moment each checkbox calls a function which contains table.toggleColumn(""); I would like to automatically read the columns names from the table. I thought about using the table.getColumns() function but I'm not sure how to get the objects into variables so I can use them. This may not be a good method though... I'm open to suggestions .

Perhaps there is a widget plug in which can work with tabulator? I was not able to find any though.

Here's my code:

HTML:
Just a hover dropdown example from w3schools modified a bit. LINK

<div class="dropdown">
  <button onclick="myFunction()" class="dropbtn">
    <span class=""></span>
  </button>

  <div id="myDropdown" class="dropdown-content">
    <ul class="items">
    <li><input  type="checkbox" onclick="myFunction1()">ID Toggle</a></li>
    <li><input  type="checkbox" onclick="myFunction2()">Vehicle Toggle</a></li>
    <li><input  type="checkbox" onclick="myFunction3()">Date Serviced From Toggle</a></li>
    <li><input  type="checkbox" onclick="myFunction4()">Date Serviced To Toggle</a></li>
</ul>
  </div>
</div>

CSS:
Dropdown styling.

.dropbtn {
  background-color: rgb(187, 202, 187);
  color: white;
  padding: 16px;
  font-size: 9px;
  border: none;
  cursor: pointer;
  background: url(http://www.stackoverflow.com/favicon.ico) 50% no-repeat #eee;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  
  display: none;
  font-size: 11px;
  position: absolute;
  right: 80;
  border: 1px solid black;
  outline-style: outset;
  outline-color: lightblue;
  background-color: #c0b9b9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown:hover .dropbtn {
  background-color: lightblue;
}

JS:
Js functions in my tables script.

//column toggle functions
function myFunction1() {
  table.toggleColumn("id");
}

function myFunction2() {
    table.toggleColumn("Assigned To");
//var cols = table.getColumns() //get array of column components
//console.log(JSON.stringify(cols))
}

function myFunction3() {
  table.toggleColumn("Name");
}
function myFunction4() {
  table.toggleColumn("Surname");
}

ezgif com-video-to-gif

So I want to remove the redundant JS functions and getcolumns() to automatically get the columns. Let me know if you need any more info.

Thanks

you can have a common function then pass the Name of the column as parameter .

Like,
"onclick="myFunction('id')"

function myFunction(nameOfColumn) {
table.toggleColumn(nameOfColumn);
}

Cheers,
Naveen Selvaraj

@olifolkerd
Copy link
Owner

Hey @NaveenSelvaraj

There is now Context Menu functionality built into Tabulator as standard as of the 4.6 release in March.

Cheers

Oli :)

@pseudozach
Copy link

Context Menu is fantastic but is it possible to use it when autocolumns=true ? Would I need to traverse all created columns and add contextmenu one by one afterwards? Is it possible to enable contextmenu on auto created columns?

@olifolkerd
Copy link
Owner

@pseudozach

Checkout the 4.8 release next weekend, it will have some new features to help with your problem.

Cheers

Oli :)

@MohanrajNataraj
Copy link

MohanrajNataraj commented Dec 3, 2020

Hi,
I am looking for Column toggle widget with persistence in tabulator. Please provide some examples
We use tabulator 4.8.4

Regards,
Mohan

@olifolkerd
Copy link
Owner

Mohan, If.you would like assistance please ask the question on stack overflow, this issue list is now only for.bug reports and feature requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Possible small update to an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants