Why state saving doesn't work for columns visibility only?

Why state saving doesn't work for columns visibility only?

lodmikulodmiku Posts: 25Questions: 2Answers: 1

Using latest version of DT and its extensons like Buttons and ColReorder I found that saving state fo columns visibility is not working. Its fine for ColReorder and things like start, length etc. Anyone was in the same situation? Cheers

This question has an accepted answers - jump to answer

«1

Answers

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    State saving with column visibility seams to work okay here. Can you link to a test case showing the issue please (as required in the forum rules).

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Hi, I've managed to move data to live server, so here's link to test case: http://debug.datatables.net/ofezuv . Together with issue I mentioned yesterday I've noticed that exporting to excel isn't working properly as I am getting an empty file.Also after page refresh styling for column visibility popover isn't applied. Could you have a look what am I doing wrong?
    Oh, and after I linked to all newly updated datatable files I got:
    TypeError: a[c].replace is not a function in buttons.html5.js
    Fix like String(row[i]) on line 530 solved that error, at least in console.
    Cheers

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    Can you try using the nightly versions of ColReorder and Buttons please. That should resolve the Buttons issue at the very least.

    If that doesn't work, can you give me a link to the page on your live server please.

    Thanks,
    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    HI, I'm getting 404 Not Found when trying to use nightly versions (files not loading).
    Live url is: http://bit.ly/1RjPbCe - it's with normal not nightly files.
    Thank you

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    Which URL specifically are you getting a 404 from?

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1
  • lodmikulodmiku Posts: 25Questions: 2Answers: 1
    edited October 2015

    Ok, I found a typo in this link instead of "colvis" should be "colVis".
    Now all files are loaded, but table layout is broken and I get same error as before:
    TypeError: a[c].match is not a function in buttons.html5.min.js when trying to download excel file.

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    Can you try it again now (including clearing your cache). I've committed another update.

    If that doesn't help, I'd need a link to the page.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1
    edited October 2015

    Still no luck. Table layout looks better now, but exported excel file is still empty, table state isn't saved and loaded properly. And I'm not able to toggle column visibility. In bottom left corner of the table I get: Showing 201 to 59 of 59 entries - which is strange too.
    Site url: http://bit.ly/1RjPbCe . Thanks

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    Column visibility - the error here is that buttons.dataTables.min.css is being loaded rather than buttons.bootstrap.min.css (which you need since you are loading the Bootstrap JS file for Buttons).

    Excel: This isn't working due to the following:

    <img src="http://www.chemiq.pl/dev/_chemiq/_pictograms/2014-09-16/k5w3tby4c6.jpg" width="30" height="30">

    And similar values which are not valid XML tags. Buttons should strip the HTML. I will look into why it is now.

    Save saving: Does it work if you remove your custom state saving code?

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1
    edited October 2015

    Hi,
    column visibility - proper file is loaded now, although at the beginning styling of visibility toggle is fine, after a few page refreshes styling is not applied.
    excel - To omit column with images I used for excelHtml5:

     exportOptions: {
                        columns: ':visible'
                    }
    

    but generated file is still with no data.
    state save - I removed my custom code and state saving seems to work now. I've no idea what I was doing wrong as state was saved and loaded as valid json from mysql database. Any advice? Thanks

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1
    edited October 2015

    I've put my custom code for state save back - it's needed between user sessions. Why it doesn't save state of columns visibilty? I found in the consloe that state is loaded and immediately saved, followed by table ajax data load. I not sure if it's even relevant to that issue, just guessing. Thanks

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    Why it doesn't save state of columns visibility?

    I'm not sure I'm afraid. I'll try to find some time later in the week to debug your code, but I can't promise to do so (things a very busy atm!). All I can really suggest is that you add some debug to make sure that you are returning a valid state form the state load function.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Yeah, Any help is welcomed. I checked again - state loaded is valid json.
    How about buttons/excel - can html tags be striped or I'm not allowed to use any images in columns. Thanks

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    The HTML should be getting striped already. That is a bug that I need to look into.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1
    edited October 2015

    Ok, if you could have a look in the console what's loaded and what's saved as state. Maybe you'll see something "out of pattern". So far I'm seeing only json :) Thanks

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    And I noticed something weird - when I drag and drop a column to reorder it for the first time after opening the page, css styling is not applied to columns visibility popover.

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Hi, Allan
    Any news on on HTML striping by Buttons extension (possible that is why excel exporting is not working on my site)? Did you resolved issue with disappearing bootstrap styling on columns visibility popover happening when reordering columns? I'm in real need for these to work. How could I help? How to debug it? Is there a way to see an XML generated by buttons?

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    No updates sorry. I've had to work on other things. I'll post here when I do get a change to work on them. If this is urgent for you priority support is available.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Hi, Trying to help: in MS Excel I'm getting an alert that .xlsx file is broken or damaged, after clicking OK (Excel tries t fix it) I'm getting data in table, except images are presented as img html tags. In latest Open Office, while trying to open .xlsx file, there is no alert, but spreadsheet has no data in it. Is it possible to show images in datatables, but in generated file to replace them with image symbol (short text)? Cheers

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    The HTML should be getting striped - that it isn't is a bug (although i tried this recently and it seemed to work for me). Can you link to the page showing the issue do I can debug it directly please? There is no option to show images in the Excel file that Buttons creates and that is not a feature an I'm currently planning to add.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Hi, link is http://bit.ly/1RjPbCe . Instead of images in exported excel file, is it possible to "pass" row's or cell's background color from datatable to generated spreadsheet? Thanks

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    Thank you for the link. It turned out that the dates in the format YYYY-MM-DD were causing the issue - Buttons was incorrectly detecting this as a number, writing that into the XML and then Excel not being happy about data in that format being called a number.

    I've committed the change and your page should export valid Excel files not. Thanks for your help again.

    is it possible to "pass" row's or cell's background color from datatable to generated spreadsheet

    Currently no - sorry. That is not something that the Buttons Excel export supports. I how to add such options in future.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Excel file has no errors now - thank you a tone. Img tags are stripped now - is it possible to show images in datatables, but only short text instead of image in exported file? And I noticed something - when I drag and drop a column to reorder it for the first time after opening the page, css styling is not applied to columns visibility popover. Cheers

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    is it possible to show images in datatables, but only short text instead of image in exported file?

    Yes - you would use the orthogonal data options of Buttons - which is demonstrated in the code here. That example hasn't been published yet but will be soon.

    when I drag and drop a column to reorder it for the first time after opening the page, css styling is not applied to columns visibility popover

    If you are using Bootstrap then that is a known issue and I will fix it before the next release.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Thank you! I'm having fun with child rows now. I can't get them exported with parent rows to excel. Is there solution for it? Thanks

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    No - the child rows are not included in the export data.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1

    Thanks Allan. Is there a way to integrate child rows with colvis and colreorder?

  • allanallan Posts: 63,201Questions: 1Answers: 10,414 Site admin

    As far as I am aware they should work already. If not, please link to a test case showing the issue.

    Allan

  • lodmikulodmiku Posts: 25Questions: 2Answers: 1
    edited November 2015

    Hi, Live site is at: http://bit.ly/1RjPbCe . I formated each child row as a separate tr, so they look like they are a part of main datatable, when shown/opened. Please try clicking green "plus" button on name test - child rows appear. But when I use colreorder or colvis layout of those child rows is broken. How to make them respond to changes made by colvis and colreorder? Thanks

This discussion has been closed.