column().state() a function that would be useful?

column().state() a function that would be useful?

JammySlayerJammySlayer Posts: 39Questions: 11Answers: 2

If you are doing any custom state saving against a column then it's a bit of a pain to then access it, such as the following:

        var filtered = false;
        table.columns().every(function(){
            if (
                this.search().trim().length > 0 ||
                (
                    this.settings().state().columns[this.index()].filter &&
                    this.settings().state().columns[this.index()].filter.length > 0
                )
            ){
                filtered = true;
                return false;
            }
        });
        return filtered;

Be a lot nicer if I could have done column().state().<Custom variable>

(I'm aware that filter might not be the best variable name but I'm using it in a custom filter)

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin
    Answer ✓

    Thanks for the suggestion.

    You can drop the settings() part, which makes a little bit less code. However, I take your point, it could perhaps be easier yet. I'm slightly concerned about the fact that this, and its matching methods for the other parts of state saving would add to the code size of DataTables (even its only a few 10Ks), so it isn't something I'm likely to add in the short term, but it is something I will keep in mind.

    Allan

This discussion has been closed.