Giter Club home page Giter Club logo

colvis's Introduction

Important - this is retired software

Please note that ColVis has now been retired and replaced by the Buttons extension which offers significant improvements and consistent styling and API integration with the rest of DataTables and the other extensions.

It is strongly recommended that you upgrade is possible to Buttons with its column visibility module, and not to use ColVis in any new projects.

ColVis

ColVis adds a button to the toolbars around DataTables which gives the end user of the table the ability to dynamically change the visibility of the columns in the table:

  • Dynamically show and hide columns in a table
  • Very easy integration with DataTables
  • Ability to exclude columns from being either hidden or shown
  • Save saving integration with DataTables

Installation

To use ColVis, first download DataTables ( http://datatables.net/download ) and place the unzipped ColVis package into a extensions directory in the DataTables package. This will allow the pages in the examples to operate correctly. To see the examples running, open the examples directory in your web-browser.

Basic usage

ColVis is initialised using the C option that it adds to DataTables' dom option. For example:

$(document).ready( function () {
    $('#example').dataTable( {
        "dom": 'C<"clear">lfrtip'
    } );
} );

Documentation / support

GitHub

If you fancy getting involved with the development of ColVis and help make it better, please refer to its GitHub repo: https://github.com/DataTables/ColVis

colvis's People

Contributors

augmt avatar ceefour avatar dustinrc avatar iiseymour avatar msimerson avatar potatosalad avatar smithk86 avatar wicker25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colvis's Issues

Default hide column doesn't work

Hi,

I have a datatable and I'd like to hide one of the columns. I've used "bVisible : false" but it doesn't seem to work.
Below is my code:

var validatedActivitiesTable = $('#validatedActivitiesTable')
                .DataTable(
                        {
                            "sDom" : "<'dt-toolbar'<'pull-left'f><'pull-right'C><'pull-right margin-right-5'l>r>"
                                    + "t"
                                    + "<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-sm-6 col-xs-12'p>>",
                            "autoWidth" : true,
                            "bStateSave" : true,
                            "preDrawCallback" : function() {
                                // Initialize the responsive datatables helper once.
                                if (!responsiveHelper_validatedActivitiesTable_col_reorder) {
                                    responsiveHelper_validatedActivitiesTable_col_reorder = new ResponsiveDatatablesHelper(
                                            $('#validatedActivitiesTable'),
                                            breakpointDefinition);
                                }
                            },
                            "rowCallback" : function(nRow) {
                                responsiveHelper_validatedActivitiesTable_col_reorder
                                        .createExpandIcon(nRow);
                            },
                            "drawCallback" : function(
                                    oSettings) {
                                responsiveHelper_validatedActivitiesTable_col_reorder
                                        .respond();
                            },
                            "aoColumns" : [ null, null, null, null, null, null, null, null, null, { "bVisible" : false} , null, null, null, null ],
                            "order" : [ [ 0, "asc" ] ],
                            "fnInitComplete": function() {
                                var oSettings = $('#validatedActivitiesTable').dataTable().fnSettings();
                                for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ ){
                                    oSettings.aoPreSearchCols[i].sSearch = '';
                                }
                            }
                        }).search("").draw(false);

I'm not sure why it doesn't work because I'm pretty sure the syntax is correct. Did I do anything wrong in the code? Please kindly help.

Thank you in advance.

Provide LICENSE file

Please provide LICENSE (or similar) file with explicit information under what license(s) ColVis is distributed.

Thank you!

Incorrect code for checkbox toggling in jQuery 1.9

In jQuery 1.9, the usage of .attr() and .prop() have changed. See the jQuery 1.9 upgrade guide.

This affects the following pieces of code in ColVis:

For checking a checkbox

Incorrect:

$('input', this.dom.buttons[i]).attr('checked','checked');

Correct:

$('input', this.dom.buttons[i]).prop('checked', true);

For un-checking a checkbox

Incorrect:

$('input', this.dom.buttons[i]).removeAttr('checked');

Correct:

$('input', this.dom.buttons[i]).prop('checked', false);

Call stateChange before the other callbacks

Currently, the stateChange callback is the last function to be called after hiding/showing a column (colVis.js:640).

If stateChange callback is moved to a place before the other callbacks, then an application can know which column was hidden/shown before the table redraws. The main use case for this is when I'm tracking column visibility outside of the dataTables API and need to use it during one of the other callbacks, like createdRow or rowCallback. I add data-* attributes to DOM elements during the other callbacks based on which columns are visible.

$.browser.msie does not work with jQuery 1.9

This line is incompatible with jQuery 1.9:

if ( $.browser.msie && $.browser.version == "6.0" )

From the jQuery 1.9 upgrade guide:

The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If needed, it is available as part of the jQuery Migrate plugin. We recommend using feature detection with a library such as Modernizr.

It seems the options for resolving this could be:

  1. Require the jQuery Migrate plugin and use the existing code
  2. Require Modernizr, and rewrite this condition as a Modernizr call
  3. Drop IE6 support and remove this block

None are really ideal. I've just commented out this section since we don't need to support IE6 in my project.

Cannot read property 'length' of undefined

On line 434.
I'm using dataTables 1.9.4. Newest TableTools and newest ColVis.

Whenever I'm trying to initialize colVis for any of tables I get this error.

Code for initialization:
var table = $('table.datatable').dataTable()

var colvis = new $.fn.dataTable.ColVis( table );

$( colvis.button() ).insertAfter('div.info');

Restore button together with state saving

When using state saving the restore button uses the visibility settings from the loaded state instead of the original once that was given when creating the DataTable.

I think it makes more sense to use the original once.

Create a package.json for NPM installation

Hi,
We use datatables-colvis as a dependency in our PatternFly toolkit (patternfly.org), however some of our consumers only use NPM to install PatternFly, so they currently can not get the datatables-colvis dependency since there isn't currently an official published NPM package for datatables-colvis.

We are planning on publishing an NPM for datatables-colvis, but it would be ideal if there was an official NPM.

Thanks,
Dave Taylor

Create a composer.json to install plugin with composer

Hi,

I am using Composer for my projects and I really loved the possibility to install datatables with composer even if it is more a js project.
Could you include a composer.json so that also can install this plugin with composer ?

thx

fnRebuild - fnSettings() no longer exists...

It seems the DataTables object doesn't have a fnSettings method anymore. It does have a settings() method. I fixed the code by changing it to this, no idea if this is correct, but it's working for me.

    //nTable = oTable.fnSettings().nTable;
    nTable = oTable.settings()[0].nTable;

[enhancement] Add missing bower.json.

Hey, maintainer(s) of DataTables/ColVis!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library DataTables/ColVis is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "DataTables/ColVis",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

add support for i18n

While the button text can freely be set at init time, it seems to me there's no real support for i18n. It would be quite useful if ColVis for example used DataTables' i18n facility.

Use of <button> element in Show / Hide list breaks in Firefox

In Firefox 4.0.1 click events on a <button> element do not get propagated down to child input elements. This is expected since the the (button standard)[http://www.w3.org/TR/html4/interact/forms.html#h-17.5] does not allow for nesting of <input> fields inside a button.

This means that clicks on the <button> element in the Show / Hide dropdown list do not change the <input type='checkbox>
settings. I would suggest switching the <button> over to a <div> and applying styling manually or removing the checkbox and storing column-visibility state elsewhere.

groupButtons collection is not being rebuilt on rebuild

rebuild method has following code to clear this.dom.buttons collection:

this.dom.buttons.splice(0, this.dom.buttons.length);

But there is no code to clear this.dom.groupButtons collection, following would do:

this.dom.groupButtons.splice(0, this.dom.groupButtons.length);

As a result, calling rebuild() does not rebuilds checked and indeterminate properties' values on input elements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.