Axapta : Refresh Data in grid

การ Refresh หรือ Update Data ใน grid ทำได้โดยเรียกใช้ method ของ datasource
ทำได้สองวิธี คือ
1.ใช้ xxx_ds.executeQuery() วิธีนี้จะเป็นการ query ใหม่ ทำให้เสีย focus ไปจาก record เดิม แต่ข้อมูล update ทันที

2. ใช้ xxx_ds.reRead() วิธีนี้จะเป็นการอ่านขึ้นมา record เดียวคือ record ที่เลือกอยู่ แต่จะไม่เห็นผลทันที ต้องเปลี่ยน record จึงจะเห็นผล

3.ใช้

xxx_ds.relead();
xxx_ds.research();
xxx_ds.findRecord();

เพื่อให้ record ที่ filter ไว้ยังคงอยู่ ดังตัวอย่าง

void clicked()
{
PurchLine tmpPurchLine;
PurchLine updatePurchLine;
PurchLine selectedRecord;

Dialog dl;
DialogField dlfTransdate;
;

dl = new Dialog("Change confirmed date");
dlfTransdate = dl.addFieldValue(typeid("Transdate"),today(),"Confirmed date");
if(dl.run()){
selectedRecord = PurchLine_ds.cursor();
for (tmpPurchLine = PurchLine_ds.getFirst(true) ? PurchLine_ds.getFirst(true) : PurchLine_ds.cursor();
tmpPurchLine; tmpPurchLine = PurchLine_ds.getnext())
{
ttsbegin;
SELECT FORUPDATE updatePurchLine
WHERE updatePurchLine.PurchId == tmpPurchLine.PurchId
&& updatePurchLine.VendAccount == tmpPurchLine.VendAccount
&& updatePurchLine.LineNum == tmpPurchLine.LineNum
&& updatePurchLine.ItemId == tmpPurchLine.ItemId;
updatePurchLine.ConfirmedDlv = dlfTransdate.value();
updatePurchLine.update();
ttscommit;
}
PurchLine_ds.reread();
PurchLine_ds.research();
PurchLine_ds.findRecord(selectedRecord);
}
super();
}

Comments

Popular posts from this blog

Artillery Hornet + OctoPrint + Klipper

ย้ายบ้าน

ใต้ร่มกาสาวพัตร