axapta: تحديث formtreecontrol بعد تغيير الصورة
-
19-09-2019 - |
سؤال
في أساليبي الأخرى (البيانات والنصوص وما إلى ذلك) تعمل طريقة Setitem على ما يرام لعرض التغييرات التي تم إجراؤها على عنصر شجرة. ومع ذلك، لا يبدو أن استدعاء SETITEM بعد تغيير أيقونة العنصر له أي تأثير. ما هي أفضل طريقة لتحديث عنصر الشجرة حتى يظهر الرمز الجديد؟
شكرًا
public void modified()
{
FormTreeItem workingItem;
;
super();
//find the current item
workingItem = FormTreeControl.getItem(FormTreeControl.getSelection());
//update the value
workingItem.Image(1);
//update the item in the list
FormTreeControl.setItem(workingItem);
}
المحلول
وجدت اثنين من القضايا هنا:
1. لم تجد أبدا وسيلة لتحديث الرمز على عنصر شجرة بفعالية.
2. اكتشف بعض كائنات التحكم في الأشجار غير تهيئ إذا حاولت إضافة / حذف من طريقة بيانات DataSource، لذلك حذف العناصر يلقي الكائنات غير تهيئة الأخطاء.
إصلاحها عن طريق:
1. إنشاء عنصر جديد (addafteridx من العنصر القديم).
2. حذف العنصر القديم.
3. حدد العنصر الجديد.
3. حرك الطريقة من DataSource إلى عنصر تحكم النموذج الفعلي.
إليك الرمز الذي عمل لي:
public boolean modified()
{
boolean ret;
FormTreeItem workingItem = FormTreeControl.getItem(currentEditingIdx);
TreeItemIdx newItemIdx;
;
ret = super();
//create a new item
newItemIdx = SysFormTreeControl::addTreeItem(FormTreeControl, workingItem.text(), FormTreeControl.getParent(workingItem.idx()), workingItem.data(), element.imageIdx(ABC_Icon.text()));
//delete the old item
FormTreeControl.delete(currentEditingIdx);
//select the new item
FormTreeControl.selectionChanged(FormTreeControl.getItem(FormTreeControl.getRoot()), FormTreeControl.getItem(newItemIdx), FormTreeSelect::Unknown);
return ret;
}
لا تنتمي إلى StackOverflow