AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 08.11.2012, 11:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Malaysia: Using a tree control
Источник: http://axmas.blogspot.com/2012/11/us...e-control.html
==============


1. In the AOT, create a new class named BudgetModelTree with the following code:
class BudgetModelTree
{
FormTreeControl tree;
BudgetModelId modelId;
}


public void new(FormTreeControl _formTreeControl, BudgetModelId _budgetModelId)
{
tree = _formTreeControl;
modelId = _budgetModelId;
}


public static BudgetModelTree construct(FormTreeControl _formTreeControl, BudgetModelId_budgetModelId = '')
{
return new BudgetModelTree(_formTreeControl, _budgetModelId);
}


private TreeItemIdx createNode(TreeItemIdx _parentIdx, BudgetModelId _modelId, RecId _recId)
{
TreeItemIdx itemIdx;
BudgetModel model;
BudgetModel submodel;
model = BudgetModel::find(HeadingSub::Heading, _modelId);
itemIdx = SysFormTreeControl::addTreeItem(tree, _modelId + ' : ' + model.Txt, _parentIdx, _recId, 0,true);


if (modelId == _modelId)
{
tree.select(itemIdx);
}

while select submodel
where submodel.ModelId == _modelId && submodel.Type == HeadingSub::SubModel
{
this.createNode(itemIdx, submodel.SubModelId, submodel.RecId);
}
return itemIdx;
}


public void buildTree()
{
BudgetModel model;
BudgetModel submodel;
TreeItemIdx itemIdx;
tree.deleteAll();
tree.lock();
while select RecId, ModelId from model
where model.Type == HeadingSub::Heading
notExists join submodel
where submodel.SubModelId == model.ModelId &&
submodel.Type == HeadingSub::SubModel
{
itemIdx = this.createNode(FormTreeAdd::Root, model.ModelId, model.RecId);
SysFormTreeControl::expandTree(tree, itemIdx);
}
tree.unLock(true);
}



2. In the AOT, open the BudgetModel form's design, expand the Body group, then
expand the GridContainer group, and change the following property of the
BudgetModel grid control:

Property Value
Visible No

3. Create a new Tree control right below the BudgetModel grid with the
following properties:

Property Value
Name Tree
Width Column width
Height Column height
Border Single line
RowSelect Yes

4. Add the following code to the bottom of the form's class declaration:
BudgetModelTree modelTree;

5. Add the following code to the bottom of form's init():
modelTree = BudgetModelTree::construct(Tree);
modelTree.buildTree();

6. Override selectionChanged() on the Tree control with the following code:
public void selectionChanged(FormTreeItem _oldItem, FormTreeItem _newItem, FormTreeSelect _how)
{
BudgetModel model;
BudgetModelId modelId;
super(_oldItem, _newItem, _how);
if (_newItem.data())
{
select firstOnly model
where model.RecId == _newItem.data();

if (model.Type == HeadingSub::SubModel)
{
modelId = model.SubModelId;

select firstOnly model
where model.ModelId == modelId && model.Type == HeadingSub::Heading;
}
BudgetModel_ds.findRecord(model);
BudgetModel_ds.refresh();
}
}

7. Override the delete() method on the BudgetModel data source with the
following code:

public void delete()
{
super();
if (BudgetModel.RecId)
{
modelTree.buildTree();
}
}

8. Override the delete() method on the SubModel data source with the
following code:

public void delete()
{
super();
if (SubModel.RecId)
{
modelTree.buildTree();
}
}

9. Add the following code to the bottom of the write() method on the BudgetModel
data source:
modelTree.buildTree();

10. Override the write() method on the SubModel data source and add the following
code to its bottom:
modelTree.buildTree();

11. In the AOT, the BudgetModel form should look like the following screenshot:



12. To test the tree control, open Budgeting | Setup | Budget models. Notice how the
ledger budget models are presented as a hierarchy:







Источник: http://axmas.blogspot.com/2012/11/us...e-control.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
ax_gfm_framework_team: Integrating a Source Document with Budget Control Blog bot DAX Blogs 0 18.07.2012 00:11
axinthefield: Journals - Balance Control Accounts Blog bot DAX Blogs 0 21.06.2011 12:11
emeadaxsupport: Renaming an AOT object in Dynamics AX 2009 that is under source control with Team Foundation Server Blog bot DAX Blogs 0 06.10.2009 02:05
mscrm4ever: Creating a Network Path Text Control Blog bot Dynamics CRM: Blogs 0 21.03.2009 06:43
Malaysia: Set Control and Keyborad Enter Blog bot DAX Blogs 0 15.08.2007 13:00

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 12:56.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.