Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Invisible column property not working #57

Closed
fdelapena opened this issue Nov 5, 2014 · 16 comments
Closed

Invisible column property not working #57

fdelapena opened this issue Nov 5, 2014 · 16 comments
Assignees

Comments

@fdelapena
Copy link
Contributor

According with documentation examples, this column shouldn't be rendered with this option:

// Server-side example
$this->getColumnBuilder()
    ->add('somecolumn', 'column', array('visible' => false));

In order to pass some column name to route_parameters these column names are needed to be provided to the column builder but sometimes are not desired to be rendered (e.g. remote column IDs), so fixing this feature without hiding it with class hacks is a nice one to have.

Also, doing display:none to th and td instead of skipping rendering "conflicts" with datatables-responsive extension, showing a "plus" to show this hidden column, which it is not desired too.

@hmillet
Copy link

hmillet commented Jan 7, 2015

Same problem for me, for the same goal. Having the id in the table but not visible.

option array('visible' => false) does not work

👍

@stwe
Copy link
Owner

stwe commented Jan 10, 2015

I can not find any issue. Is this a problem with CSS?

@hmillet
Copy link

hmillet commented Jan 10, 2015

I just don't know...

My scenario :

  • I add this on a datatable :
->add('id', 'column', array('visible' => false))
  • I refresh my web page
  • I can see this new column
  • In the page source, I can see this generated js code, that's seems right :
var columns = {
  "columns": [
     {
        "searchable": true,
        "orderable": true,
        "visible": false,
        "title": "",
        "className": "",
        "defaultContent": "",
        "width": "",
        "contentPadding": "",
        "name": "",
        "data": "id",
     },

Then, I don't know how datatable.js should hide this column... probably with CSS. Anyway, in the element inspector, I can't see any specific CSS class on this column and its cells so that they are hidden :-(

@stwe
Copy link
Owner

stwe commented Jan 10, 2015

please try only:

'%kernel.root_dir%/../vendor/datatables/datatables/media/css/jquery.dataTables.css'

@hmillet
Copy link

hmillet commented Jan 10, 2015

Does not work...

I removed my assets installed with bower, I install the recommended bundle with composer "datatables/datatables": "1.10.4", and finally put the new css and js in my base template :

        {% stylesheets  '%kernel.root_dir%/../vendor/datatables/datatables/media/css/jquery.dataTables.css' output="css/jquery.dataTables.css" %}
            <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}
../..
        {% javascripts  '%kernel.root_dir%/../vendor/datatables/datatables/media/js/jquery.dataTables.js' output="js/jquery.dataTables.js" %}
            <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}

Then, when I add this on my datatable, the new column still appears :

->add('id', 'column', array('visible' => false))

@stwe
Copy link
Owner

stwe commented Jan 10, 2015

cache cleared?
Am 10.01.2015 14:31 schrieb "Herve MILLET" notifications@github.com:

Does not work...

I removed my assets installed with bower, I install the recommended bundle
with composer "datatables/datatables": "1.10.4", and finally put the new
css and js in my base template :

    {% stylesheets  '%kernel.root_dir%/../vendor/datatables/datatables/media/css/jquery.dataTables.css' output="css/jquery.dataTables.css" %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}

../..
{% javascripts '%kernel.root_dir%/../vendor/datatables/datatables/media/js/jquery.dataTables.js' output="js/jquery.dataTables.js" %} <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

Then, when I add this on my datatable, the new column still appears :

->add('id', 'column', array('visible' => false))


Reply to this email directly or view it on GitHub
#57 (comment)
.

@hmillet
Copy link

hmillet commented Jan 10, 2015

Yes sir !

Can you explain me how datatable should hide a column with visible: false ?

It puts a css class on column or somewhere ? or it does just create the dom for this column ?

@stwe
Copy link
Owner

stwe commented Jan 12, 2015

see the answer: https://datatables.net/forums/discussion/25416/how-datatable-should-hide-a-column-with-visible-false

The one common 'gotcha' is using Responsive with column visibility, since Responsive controls the column visibility. You can add the class never to a column if you never want it to be visible.

@stwe
Copy link
Owner

stwe commented Jan 13, 2015

It works after a change of "visible" everything properly. You still have to delete the browser's cache.

@exploitation
Copy link

Thanks a lot Steffen.

But I can't understand what means "a change of "visible" everything properly"

@stwe
Copy link
Owner

stwe commented Jan 13, 2015

I change from "visible=>false" to "visible=>true".....or "visible=>true" to "visible=>false".
This works for me only if I delete the cache of the browser.

@stwe stwe self-assigned this Jan 13, 2015
@hmillet
Copy link

hmillet commented Jan 13, 2015

Ok, I will try this tomorrow and tell you.

@fdelapena
Copy link
Contributor Author

Thanks @stwe, looks like the gotcha mentioned by allan with Responsive datatables extension is the reason for my case, as I'm using it.

The Responsive documentation for the class never is here:
https://datatables.net/extensions/responsive/classes#Special-classes

@hmillet are you using this extension too?

@stwe
Copy link
Owner

stwe commented Jan 15, 2015

@fdelapena , i can add:

    {% if column.visible %}
        "visible": true,
        "className": "{{ column.className }}",
    {% else %}
        "visible": false,
        "className": "never {{ column.className }}",
    {% endif %}

@stwe stwe closed this as completed in 208c96e Jan 15, 2015
@fdelapena
Copy link
Contributor Author

Thanks, looks good to me to have it in, as the Responsive extension looks popular and doesn't bloat much the code result when unused.

@hmillet
Copy link

hmillet commented Jan 27, 2015

@stwe : Now that I understand that "cache cleared" means "browser cache", that's work fine for me, sorry for this misunderstanding...

@fdelapena : Hi ! I don't use the Responsive datatables extension, but... it seems great, I probably do it soon ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants