Getting rowid from settings

Getting rowid from settings

lumolumo Posts: 3Questions: 2Answers: 0

I am trying to get the setting for rowid
NOTICE: i know that the rowid can be more complex, than a simple string - but in my case it is just as simple.

I created an "example", which creates a table as described above, whith a button that accesses the grid.settings() and shall assign the rowid
http://live.datatables.net/tifivise/1/edit

So the grid is generated using

rowId: 'staffId'

How do I get this setting at runtime?

I thought it could be accessible via settings() but I was not able to find it.
https://datatables.net/reference/api/settings()

Any help welcome.
Thanks in advance!

This question has an accepted answers - jump to answer

Answers

  • lumolumo Posts: 3Questions: 2Answers: 0

    NOTE:
    i found a dirty workaround, which is not supposed to be used in production environment...

    $("#RowIdButton").click( function() {
      let rowid = "how to access the rowid setting?"//grid.settings().valueOf("rowid");
      // find rowid via value
    for (const [key, value] of Object.entries(grid.row().data())) {
      if (value == grid.row().id()) {
        rowid = key;
        break;
      }
      console.log("key="+key+", value="+value);
    }
      $("#RowIdButton").html('rowid:'+rowid);
    });
    
  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    Answer ✓

    If you look at the settings object you will see an array. The object could hold settings for multiple tables, each in its own array element. See this example of getting settings for the first table:
    http://live.datatables.net/tifivise/4/edit

    Kevin

Sign In or Register to comment.