List Panel to the form d365fo x++
List Panel to the form d365fo x++
class DSNotificationBookmarkMethodListPanel extends SysListPanel { DSNotificationWordBookmark notificationWordBookmark; public void addData(container data) { // The bookmark field is updated at positionUpdated() method. No extra action needed here. } public void removeData(container data) { // The bookmark field is updated at positionUpdated() method. No extra action needed here. } public container getData() { container selectedData, availableData, dataItem; LabelString bookmark; availableData = this.getAvailableAllV2(); // fill in the selected list and remove the items from the available list at the same time container bookmarksContainer = notificationWordBookmark.bookmarks; for (int idx = 1; idx <= conLen(bookmarksContainer); idx++) { bookmark = conpeek(conpeek(bookmarksContainer, idx), 1); for (int i = 1; i <= conLen(availableData); i++) { dataItem = conpeek(availableData, i); if (conpeek(dataItem, 1) == bookmark) { //remove the item from the availble list availableData = conDel(availableData, i, 1); break; } } selectedData += [dataItem]; } return [availableData, selectedData]; } int numOfColumnsAvailable() { return 2; } int numOfColumnsSelected() { return 2; } public DSNotificationWordBookmark parmNotificationWordBookmark(DSNotificationWordBookmark _notificationWordBookmark, boolean refreshData = true) { notificationWordBookmark = _notificationWordBookmark; return notificationWordBookmark; } public static DSNotificationBookmarkMethodListPanel construct() { return new DSNotificationBookmarkMethodListPanel(); } public static DSNotificationBookmarkMethodListPanel newForm(FormRun _formRun, int _parentId) { DSNotificationBookmarkMethodListPanel sysListPanel = DSNotificationBookmarkMethodListPanel::construct(); sysListPanel.parmFormRun(_formRun); sysListPanel.parmParentId(_parentId); sysListPanel.parmHasAddAllButton(true); sysListPanel.parmHasRemoveAllButton(true); sysListPanel.parmHasUpDownButton(true); sysListPanel.parmShowColumnHeader(true); sysListPanel.build(); return sysListPanel; } public str parmCaptionSelected(str _captionSelected = captionSelected) { return super("Bookmark method"); } public str parmCaptionAvailable(str _captionAvailable = captionAvailable) { return super("Available method"); } private container getAvailableAll() { container availableList; DictTable dictTable; DictField dictField; tableId tableId; LabelString bookmark_data; DSNotificationBookmark notificationBookmark = new DSNotificationBookmark(); List tableList = notificationWordBookmark.getTableListForBookmarks(); if (tableList) { ListEnumerator enumerator = tableList.getEnumerator(); while(enumerator.moveNext()) { tableId = enumerator.current(); dictTable = new DictTable(tableId); for (FieldId fieldId = 1; fieldId <= dictTable.fieldCnt(TableScope::IncludeDerivedTables); fieldId++) { dictField = new DictField(tableId, fieldId); if (dictField) { bookmark_data = notificationBookmark.bookmark(tableid2name(tableId), fieldid2name(tableId, fieldId), false, false); availableList += [[bookmark_data, dictTable.label(), dictField.label()]]; } } } } return availableList; } private container getAvailableAllV2() { container availableList; SysDictTable dictTable; DictField dictField; tableId tableId; LabelString bookmark_data; DSNotificationBookmark notificationBookmark = new DSNotificationBookmark(); List tableList = notificationWordBookmark.getTableListForBookmarks(); if (tableList) { ListEnumerator enumerator = tableList.getEnumerator(); while(enumerator.moveNext()) { tableId = enumerator.current(); dictTable = new SysDictTable(tableId); Set methodSet = dictTable.methods(true, true, false); if(methodSet) { SetEnumerator methodEnumerator = methodSet.getEnumerator(); while(methodEnumerator.moveNext()) { DictMethod dictMethod = methodEnumerator.current(); bookmark_data = notificationBookmark.bookmark(tableid2name(tableId), dictMethod.name(), false, false); availableList += [[bookmark_data, dictMethod.name(), dictMethod.name()]]; } } } } return availableList; } protected container positionsUpdated() { container ret; ret = super(); container selectedBookmarks = conNull(); FormListControl selectedList = this.parmViewSelected(); int idx = selectedList.getNextItem(FormListNext::All); while (idx != -1) { selectedBookmarks += [selectedList.getItem(idx).data()]; idx = selectedList.getNextItem(FormListNext::All, idx); } notificationWordBookmark.bookmarks = selectedBookmarks; return ret; } protected Array getColumnHeaders() { Array columnHeaders = new Array(Types::Class); columnHeaders.value(1, new SysListPanelColumnHeader("@SYS318174", 120)); // "Source" columnHeaders.value(2, new SysListPanelColumnHeader("Method", 140)); // "Field" return columnHeaders; } }//Form part code[Form] public class DSNotificationWordBookmark extends FormRun { DSNotificationBookmarkListPanel notificationBookmarkListPanel; DSNotificationBookmarkMethodListPanel MethodNotificationBookmarkListPanel; boolean canEditApplicationBookmark = false; public void init() { DSNotificationWordBookmark notificationWordBookmark; //select firstonly RecId from notificationWordBookmark; if (!notificationWordBookmark.RecId) { DSNotificationBookmark notificationBookmark = DSNotificationBookmark::construct(); notificationBookmark.initTableList(); } notificationBookmarkListPanel = DSNotificationBookmarkListPanel::newForm(this, element.controlId(formControlStr(DSNotificationWordBookmark, ListPanelgroup))); MethodNotificationBookmarkListPanel = DSNotificationBookmarkMethodListPanel::newForm(this, element.controlId(formControlStr(DSNotificationWordBookmark, MethodListPanelGroup))); super(); canEditApplicationBookmark = hasTableAccess(tableNum(DSNotificationWordBookmark), AccessType::Edit); notificationBookmarkListPanel.init(); notificationBookmarkListPanel.parmNotificationWordBookmark(DSNotificationWordBookmark); MethodNotificationBookmarkListPanel.init(); MethodNotificationBookmarkListPanel.parmNotificationWordBookmark(DSNotificationWordBookmark); } public int task(int _taskId) { #task int ret; ret = super(_taskId); switch (_taskId) { case #taskEditRecord: case #taskDoneEditRecord: this.fillBookmarkListPanelWithViewMode(); break; } return ret; } private void fillBookmarkListPanelWithViewMode() { notificationBookmarkListPanel.parmOnlyViewAccess(this.inViewMode() || !canEditApplicationBookmark); notificationBookmarkListPanel.fill(); MethodNotificationBookmarkListPanel.parmOnlyViewAccess(this.inViewMode() || !canEditApplicationBookmark); MethodNotificationBookmarkListPanel.fill(); } [DataSource] class DSNotificationWordBookmark { public int active() { int ret; ret = super(); element.fillBookmarkListPanelWithViewMode(); return ret; } /// <summary> /// /// </summary> public void init() { super(); this.query().dataSourceName(this.name()).addRange(fieldNum(DSNotificationWordBookmark,NotificationType)).value(SysQuery::valueNot(DSNotificationType::Custom)); } } }
Comments
Post a Comment