Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82087

Datatable editor with node.js & knex - Access options value with dotted key or rename key

$
0
0

I'm using datatable editor with node.js and knex.js. When rendering a field ... I can add a options list to it like this:

datatable editor node.js using knex.js :

new Field('users.site')
    .options(new Options()
        .table('sites')
        .value('id')
        .label('name')
    );

To access the json I can call the table and look for options:

javascript:

table_users.on( 'xhr', function () {
    var jsonOptions = table_users.ajax.json().options;
    console.log(jsonOptions);
} )

If I output it I get:

console.log

{…}
    "users.site": (4) […]
        0: Object { label: "A", value: "A" }
        1: Object { label: "B", value: "B" }
        2: Object { label: "C", value: "C" }
        3: Object { label: "D", value: "D" }
        length: 4
        <prototype>: Array []
        <prototype>: {…   

... but I'm not able to access the "users.site" array ... when I do this:

table_users.on( 'xhr', function () {
    var jsonOptions = table_users.ajax.json().options;
    console.log(jsonOptions.users.site);
} )      

... I'm getting an error in the console:

TypeError: jsonOptions.users is undefined

Obviously I can call jsonOptions.users.site ... but how can I access those values? Can I rename the options access key for instance? (If its possible to change the key name ... I would only want to change it for the options key ... not for the column key though if possible.)


Viewing all articles
Browse latest Browse all 82087

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>