Change Value in Data Source

Hi all,

I am working on a grid from one datasource

Here is my grid

Line Item Qty Qty Adjustment Status

1 BT-09 100 0 Bad

2 BT-09 0 0(disabled) Good

if i change the Qty Adjustment in Line 1 (BT-09 with Bad Status) then Qty in Line 2 (BT-09 with Good Status) is also changed

For ex

Line Item Qty Qty Adjustment Status

1 BT-09 60 20 Bad

2 BT-09 20 0(disabled) Good

Qty in line 2 is = QtyDefault - (QtyInLine1 + QtyAdjustment)

What method should i call from datasource?

How do i write the code?

Thx

Hi all,

I am working on a grid from one datasource

Here is my grid

Line Item Qty Qty Adj Status

1 BT-09 100 0 Bad

2 BT-09 0 0 Good

if i change the Qty Adjustment in Line 1 (BT-09 with Bad Status) then Qty in Line 2 (BT-09 with Good Status) is also changed

For ex

Line Item Qty Qty Adj Status

1 BT-09 60 20 Bad

2 BT-09 20 0 Good

Qty in line 2 is = QtyDefault - (QtyInLine1 + QtyAdjustment)

What method should i call from datasource?

How do i write the code?

Thx

When line1’s update() is called, you have to find line2 (somehow, depending on your requirements), set the new quantity value and save the record. Be careful not to create an infinite sequence of updates.

When it’s done, you’ll need to research the datasource.

thx for the suggestion.

i wrote these code and return the data as i expected, but the datasource cant refresh automatically.

i need to press F5. do u see where i did wrong here?

fyi i used the leave method on field in griedline

while select forUpdate repTrans2 where repTrans2.ItemId == FKT_RepackingTrans.ItemId && repTrans2.StatusItem != FKT_RepackingTrans.StatusItem

{

ttsBegin;

repTrans2.Qty = FKT_RepackingTrans.QtyStored - FKT_RepackingTrans.Qty - FKT_RepackingTrans.QtyAdjustment;

FKT_RepackingTrans.update();

repTrans2.update();

ttsCommit;

}

FKT_RepackingTrans_ds.reread();

FKT_RepackingTrans_ds.refresh();

Doing it in field’s leave() method is a very bad idea - you update other records but the current one hasn’t been saved yet (you merely moved to another field) and may not ever be saved (user leaves the form without saving, write validation fails, network fails etc.) and you’ll end with corrupted data consistency.

You really need to do that when the record is saved and do that in the same transaction. Also, you shouldn’t run such a logic on client tier (for performance reasons).

About refresh, I suggest looking at Tutorial: refresh, reread, research, executeQuery - which one to use?.

i got it. so what do u think the best that i should use?

i got it. so what do u think the best method that i should use?

in datasource or gridline?

update() method (and insert()/delete() if applicable) directly on the table. Such a kind of logic shouldn’t be implement in forms.

What about this to refresh your grid

FKT_RepackingTrans_ds.executeQuery();

Usualy is the first datasource_ds or the datasource linked to your grid

@Dominic, why do you think that execute() query is a better choice than research()? I don’t see any reason to reset the query.

Not sure for the core details but, it just make sur that any change to the query are reflected. Plus I dont think it takes more time to run. Maybe I`m wrong…

My point is that there are no changes in the query, so there is no reason to recreate it. Users will be happier if they’re filters and sorting are kept.

research() is exactly what’s needed here, as a replacement for pressing F5.

Right…