Sunday, 15 September 2013

javascript - angular-datatables payload format does not change upon subsequent calls to reloadData() -



javascript - angular-datatables payload format does not change upon subsequent calls to reloadData() -

after initial load of info table using angular-datatables (homepage), intend alter time span reload , display data. span selected using 2 datetime input fields. however, subsequent requests not modify time window parameter in dtoptions obeject.

the unusual thing that, when console.log modified dtoptions object, changes seem take effect, - info property of dtoptions reflects newly selected time range. inspection of request in "network" tab of "developer tools" in chrome, shows old time range values still used, causes no updates table entries.

example:

this {from, to} value in "network" tab of "developers tools" whenever post new data:

origin:http://localhost:9000 referer:http://localhost:9000/ user-agent:mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/37.0.2062.120 safari/537.36 form dataview sourceview url encoded ->from:1412172055200 ->to:1412690455222

while it's equivalent in "console" tab, when issuing console.log($scope.dtoptions); reflects time range pre-selected.

object {ajax: object, reload: true, integratebootstrap: false, hascolvis: false, hascolreorder: false…} ajax: object data: object ->from: 1412518000453 ->to: 1412690800493 __proto__: object datatype: "json" type: "post"

i tried number of ways update/rewrite from , to values in payload prior calling $scope.dtoptions.reloaddata(): wrote $scope.dtoptions.ajax.from directly, tried passing updated payload object, , latest effort (code below give idea) - used newoptions() create dtoptions object anew.

var payload = { from: tfrom, to: tto }; $scope.dtoptions = dtoptionsbuilder.newoptions() .withoption('ajax', { url: constantcfg.apiendpoint+constantcfg.uri.usersstats, type: 'post', data: payload }); $scope.dtoptions.reloaddata(); console.log($scope.dtoptions); <- causes 'console' tab output discussed above

all ways, update values of payload, when printed in "console" tab, requests in "network" tab still indicate usage of old time range values.

none of ways tried update payload object caused no additional warnings or errors.

in fact, need define ajax.data function , define parameters send server.

var = 1412518000453, = 1412690800493; $scope.dtoptions = dtoptionsbuilder.newoptions() .withoption('ajax', { url: constantcfg.apiendpoint+constantcfg.uri.usersstats, type: 'get', data: function(d) { d.from= from; d.to = to; } }); $scope.reloaddata = function() { // compute from/to variables = 1412518000463; = 1412690800593; $scope.dtoptions.reloaddata(); };

javascript angularjs datatables

No comments:

Post a Comment