Is there any way of getting an specific setting programmatically?

Is there any way of getting an specific setting programmatically?

jmeilejmeile Posts: 28Questions: 4Answers: 0

Hi

I would like to get a responsive setting programmatically, for example, the current breakpoints. I debug a Datatable code and found that I can see all the responsive settings as follows:

my_table.settings()[0].responsive

There I see something like:

my_table.settings()[0].responsive
c: {…}
    auto: true
    breakpoints: (5) [...]
      0: {...}
          name: "desktop"
          width: infinity
          <prototype>: {...}
      1: {...}
          name: "tablet-l"
          width: 1024
          <prototype>: {...}
      ... More Breakpoints are listed
    ...More settings are listed
s: {...}
<prototype>: {...}

I would like to get the breakpoints, so, I tried:
my_table.settings()[0].responsive.breakpoints

Or:
my_table.settings()[0].responsive["breakpoints"]

But it always says: undefined

How can I get the breakpoints?

Best regards
Josef

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    That breakpoints object is within the c object, so you would reference that like:

    my_table.settings()[0].responsive.c["breakpoints"]
    

    Colin

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    I should note that we consider those properties to be internal. If they aren't documented in the reference then they are liable to change between even minor versions. Realistically they probably won't, but if they do, that most likely wouldn't be even mentioned in the release notes since, as I say, they are considered to be internal.

    Just a warning if you do use them :).

    Allan

  • jmeilejmeile Posts: 28Questions: 4Answers: 0

    @allan thanks for your advice. Actually, I found a better way of doing what I was looking for. I was needing this for this post:

    https://datatables.net/forums/discussion/70471/responsive-resize-event-will-be-infinitely-triggered

    One of my ideas were to figure out which view was displayed on the user's browser by getting these breakpoints and compare them with the browser dimensions, but then I realized that I could use the function: responsive.hasHidden(), which gives me what I want.

    Best regards
    Josef

Sign In or Register to comment.