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

colVis + stateSave leads to broken filters #265

Closed
jonnsn opened this issue Dec 7, 2015 · 8 comments
Closed

colVis + stateSave leads to broken filters #265

jonnsn opened this issue Dec 7, 2015 · 8 comments

Comments

@jonnsn
Copy link

jonnsn commented Dec 7, 2015

Hi,

I have a Datatable with colVis Button and stateSave option set to true.
Once I hide one or more columns and reload the page, the columns are still hidden therefore. If I want to show the columns now, there are no filters for them and I can't seem to add them on 'column-visibility.dt'.
I tried this for example:

dataTable.on('column-visibility.dt', function (e, settings, col_num, state) {
        var obj = {};
        obj[col_num] = yadcf.getOptions(settings.oInstance.selector)[col_num];
        if (obj[col_num] !== undefined) {
            obj[col_num].column_number = col_num;
            if (obj[col_num] !== undefined) {
                appendFilters(settings.oInstance.selector,
                    obj,
                    settings.oInstance.selector);
            }
        }
      });

but obviously appendFilters is not accessible here and I could not find another possibility to init the "new" columns.

I'd be happy for any suggestions :-)

@1nickt
Copy link

1nickt commented Dec 9, 2015

I also have this behavior with colVis and stateSave.

@vedmack
Copy link
Owner

vedmack commented Dec 9, 2015

please provide a link to a jsbin/jsfiddle/ etc so I can reproduce this scenario...

@1nickt
Copy link

1nickt commented Dec 9, 2015

@vedmack Thank you for your attention, here is a demo: http://live.datatables.net/kitawawo/4/edit?html,js,output

To reproduce:

  • Click button to show/hide cols.
  • Hide some cols.
  • Click back on table to close widget.
  • Refresh table (with Run with JS button)
  • State is saved, cols are hidden.
  • Make the columns visible again with the button widget.
  • Filter input is not restored.

@vedmack
Copy link
Owner

vedmack commented Dec 10, 2015

@jonnsn @1nickt , both of you are using datatables with DOM source? because if you do so then it didn't work only because I wasn't listening to the colvis events in DOM source mode, I just added it on my dropbox file and the jsbin works fine, let me know if it works for both of you and I'll commit it.
See it in action http://live.datatables.net/kitawawo/5/edit

@1nickt
Copy link

1nickt commented Dec 11, 2015

Hi, I won't get a chance to review tonight, but no, I am using JavaScript
data source.

-nick
On Dec 10, 2015 5:12 PM, "Daniel Reznick" notifications@github.com wrote:

@jonnsn https://github.com/jonnsn @1nickt https://github.com/1nickt ,
both of you are using datatables with DOM source? because if you do so then
it didn't work only because I wasn't listening to the colvis events in DOM
source mode, I just added it on my dropbox file and the jsbin works fine,
let me know if it works for both of you and I'll commit it.
See it in action http://live.datatables.net/kitawawo/5/edit


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

@jonnsn
Copy link
Author

jonnsn commented Dec 11, 2015

@vedmack : I use DOM source and it seems to fix the issue for me. Thank you very much for your help!

@1nickt
Copy link

1nickt commented Dec 11, 2015

Hi again Daniel,

Fixed!

( Using Javascript Data Source )

See http://live.datatables.net/kitawawo/8/edit

I also tested with my real site.

You are the man.

Thanks very much.

By the way, I tried many ways to get column filter boxes at the top of my
table with JS data in DataTables, including the ones on the official site
docs, and other more visible plugins, but yours was the first and only one
that I was able to get working. Thank you!

  • nick

On Thu, Dec 10, 2015 at 5:12 PM, Daniel Reznick notifications@github.com
wrote:

@jonnsn https://github.com/jonnsn @1nickt https://github.com/1nickt ,
both of you are using datatables with DOM source? because if you do so then
it didn't work only because I wasn't listening to the colvis events in DOM
source mode, I just added it on my dropbox file and the jsbin works fine,
let me know if it works for both of you and I'll commit it.
See it in action http://live.datatables.net/kitawawo/5/edit


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

@vedmack
Copy link
Owner

vedmack commented Dec 12, 2015

Fixed in 0.8.9.beta.27 grab it and see how it works for you.

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

No branches or pull requests

3 participants