GithubHelp home page GithubHelp logo

Comments (16)

hmillet avatar hmillet commented on May 17, 2024

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

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

👍

from datatablesbundle.

stwe avatar stwe commented on May 17, 2024

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

from datatablesbundle.

hmillet avatar hmillet commented on May 17, 2024

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 :-(

from datatablesbundle.

stwe avatar stwe commented on May 17, 2024

please try only:

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

from datatablesbundle.

hmillet avatar hmillet commented on May 17, 2024

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))

from datatablesbundle.

stwe avatar stwe commented on May 17, 2024

cache cleared?
Am 10.01.2015 14:31 schrieb "Herve MILLET" [email protected]:

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)
.

from datatablesbundle.

hmillet avatar hmillet commented on May 17, 2024

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 ?

from datatablesbundle.

stwe avatar stwe commented on May 17, 2024

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.

from datatablesbundle.

stwe avatar stwe commented on May 17, 2024

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

from datatablesbundle.

exploitation avatar exploitation commented on May 17, 2024

Thanks a lot Steffen.

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

from datatablesbundle.

stwe avatar stwe commented on May 17, 2024

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.

from datatablesbundle.

hmillet avatar hmillet commented on May 17, 2024

Ok, I will try this tomorrow and tell you.

from datatablesbundle.

fdelapena avatar fdelapena commented on May 17, 2024

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?

from datatablesbundle.

stwe avatar stwe commented on May 17, 2024

@fdelapena , i can add:

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

from datatablesbundle.

fdelapena avatar fdelapena commented on May 17, 2024

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.

from datatablesbundle.

hmillet avatar hmillet commented on May 17, 2024

@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 ;-)

from datatablesbundle.

Related Issues (20)

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.