0
votes

I have a Bill datasource, and a payment datasource, and the balance datasource a an sqlcalculated query.

My problem is, that when something is changing on the payment or the bill datasource, I try to unload/load automatically the balance datasource (on create or delete event on client side), but the balance still ignores the changes !

When I make exactly the same thing on a button, and press the button manually, then the balance is updating to the correct value.

Why is the query not computing the right value directly after change ? Do I need to put some kind of delay, before loading the balance ?

1
I believe to better answer your question it would help if you post your code for your 'on create or delete event on client side'. If for example you create/delete a payment via a button and you delete the item with one line of code and then immediately reload your balance datasource, then yes it will not update the balance correctly since the payment may not actually have been deleted. So it really would help to know what you are doing in your 'unload/load automatically the balance datasource' step. - Markus Malessa

1 Answers

0
votes

I guess what's happening here is that your code is calling the server-side function for creating a new item and then immediately reloading the datasource. What you might need to do is reload the datasource from from a callback after the item has been created.

button.datasource.createItem({
  success: function(record) {
    // record object contains the newly inserted record
    button.datasource.load();
  },
  failure: function(status) {
    // status contains the error message 
  }
});

Please let me know if my initial assumption is wrong and I'll edit my answer accordingly.