Searchpane - reapply selected items after data update

Searchpane - reapply selected items after data update

glimpsed_chaosglimpsed_chaos Posts: 113Questions: 22Answers: 4
edited September 2019 in Free community support

My data for tables is updated using SignalR to broadcast to my clients. As the new data comes in, the table is updated without issue. If a user had applied a searchPane filter, the new data still remains filtered. However, the style of the selected item(s) within the searchPane disappears.

How can I keep the style applied also?

This is my code after receiving new data -

        chat.client.udpatetable = function (newtableData) {
            var data = JSON.parse(newtableData);
            var table = $('#my_table').DataTable().clear().rows.add(data).draw();
            table.searchPanes.rebuild();
        }

(I would post a test case, but cannot without having a way to have the data refreshed like SignalR is wired up.)

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    edited September 2019 Answer ✓

    Hi @glimpsed_chaos ,

    We're close to making a major release for a new searchPanes extension, so watch out for that. Could you create a test case for you current one please, so we can see the issue. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • glimpsed_chaosglimpsed_chaos Posts: 113Questions: 22Answers: 4

    Colin,

    I commented in my original post that I cannot create a test case, not that I don't know how to generically speaking. Specifically, I cannot recreate the scenario as I cannot have the data refresh occurring in the same manner.

    I didn't know if I was possibly overlooking some option with the table.searchPanes.rebuild() or possibly determine what was already filtered on and reapply the css style.

    That's okay though, I am looking forward to the release of the searchPanes extension.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Without seeing it in operation, one option is to put your table.searchPanes.rebuild(); into a draw - it won't be efficient, but if the dataset is small it may be fine.

  • glimpsed_chaosglimpsed_chaos Posts: 113Questions: 22Answers: 4

    Colin,

    I tried in my local environment like you suggested but no dice. Actually, that kept the "selected" class from being applied at all, although it still filtered.

    I did create a test case here - http://live.datatables.net/dodaqohi/3/

    Although it is just a button click to clear the table, add new data, draw and then rebuild the searchPanes.

    This however, seems to work properly though. The "selected" class remains even after calling the draw and rebuild same as I do in my local. The only difference is that my new data comes in a server push (SignalR) and the test case just has a data ready to load.

    Still puzzled...

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Hi @glimpsed_chaos ,

    Thanks for that test case, that helps. I thought the problem could be because of the network delay, but I tried that here and it worked as expected. I really don't know what it could be, and searchPanes v0 is pretty limited in the API and options.

    What I would suggest is wait for the v1 release (couple of weeks) - this has a whole new approach - each seachPane is a mini-DataTable so there will be methods for reselecting options should this problem occur there.

    Not a good answer I'm afraid,

    Cheers,

    Colin

  • glimpsed_chaosglimpsed_chaos Posts: 113Questions: 22Answers: 4

    Colin,

    Thank you and yes, I understood going into it that it was in a early development stage with limited features.

    Definitely looking forward to the official new release!

This discussion has been closed.