Показать сообщение отдельно
Старый 24.04.2009, 11:55   #5  
DreamCreator is offline
DreamCreator
Moderator
Аватар для DreamCreator
Axapta Retail User
 
553 / 45 (3) +++
Регистрация: 04.11.2004
Адрес: Казань
Произвольное дерево в лукап форме

1) Создать лукап форму, в нее добавить элемент Tree
2) методы формы (таблица дерева WCCategory)

X++:
void selectItem()
{
    FormTreeItem    fti = tree.getItem(tree.getSelection());
    ;

    if (fti.data())
        this.closeSelect(fti.data());
}

public void closeSelect(str _selectString)
{
    if (_selectString)
        super(_selectString);
}

void createBranch(EShopCategoryId   _categoryId = 0,
                  int               _idx = 0)
{
    WCCategory      wcCategory, wcCategoryChild;
    FormTreeItem    fti;
    int             idx;
    ;

    while select wcCategory
        where wcCategory.ParentId == _categoryId
    {
        select wcCategoryChild
            where wcCategoryChild.ParentId == wcCategory.CategoryId;

        fti = new FormTreeItem(
            wcCategory.Name, 0, wcCategoryChild ? 1 : 0, wcCategory.CategoryId);
        idx = tree.addItem(_idx, 0, fti);
        element.createBranch(wcCategory.CategoryId, idx);
    }
}

public void run()
{
    element.createBranch();
    super();
}
3) Метод на дереве
X++:
public int mouseDblClick(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
{
    #FORMTREECONTROL

    int          ret;
    int          idx;
    int          focus;

    ret = super(_x, _y, _button, _Ctrl, _Shift);

    [idx, focus] = this.hitTest(_x, _y);

    if (focus & #FTCHT_ONITEM)
        element.selectItem();

    return ret;
}