首页 > 代码库 > Form_Form Tree树形结构的开发(案例)

Form_Form Tree树形结构的开发(案例)

2014-06-09 Created By BaoXinjian

技术分享一、摘要

 

技术分享二、解析

 

CREATE TABLE bxj_menu(   menu            VARCHAR2 (100),   submenu         VARCHAR2 (100),   menu_function   VARCHAR (100),   attribute1      VARCHAR2 (240),   attribute2      VARCHAR2 (240),   attribute3      VARCHAR2 (240),   attribute4      VARCHAR2 (240),   attribute5      VARCHAR2 (240))

 

 

BEGIN   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (0, SCM_DEPT_MENU, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (0, FIN_DEPT_MENU, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (SCM_DEPT_MENU, PO_MENU, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (SCM_DEPT_MENU, INV_MENU, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (FIN_DEPT_MENU, GL_MENU, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (FIN_DEPT_MENU, AP_MENU, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (AP_MENU, AP_FORM, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (PO_MENU, PR_FORM, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (PO_MENU, PO_FORM, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (PO_MENU, PO_QUOTATION, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (PO_QUOTATION, QUOTATION_FORM, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (INV_MENU, ONHAND_FORM, ‘‘);   INSERT INTO bxj_menu (menu, submenu, menu_function)     VALUES   (INV_MENU, TRANSACTION_FORM, ‘‘);END;

 

 2,创建一个数据块,命名为:B,
在画布上创建一个文本项,命名为TEXT1,打开属性选项板,项类型选择:层次树

 

3,创建一个记录组,命名为REC1,记录组查询代码如下:(记得别加任何Order by)

select -1 state, level, a.submenu, null Icon, a.submenu
  from xx_menu a
where a.submenu is not null
start with a.menu = ‘0‘
connect by prior a.submenu = a.menu

 

 

4,打开item:TEXT1的属性选项板,选择其记录组为REC1

5,创建trigger: WHEN-NEW-FORM-INSTANCE

内容如下:

DECLARE
    HTREE ITEM;
    v_ignore NUMBER;
    rg_emps RECORDGROUP;
BEGIN
    HTREE := FIND_ITEM(‘B.TEXT1‘);
    FTREE.POPULATE_TREE(HTREE);
    rg_emps := FIND_GROUP(‘REC2‘);
    IF NOT ID_NULL(rg_emps) THEN
      DELETE_GROUP(rg_emps);
    END IF;
    rg_emps := CREATE_GROUP_FROM_QUERY(‘rg_emps‘,‘select -1 state, level, a.submenu, null Icon, submenu
  from xx_menu a
where a.submenu is not null
start with a.menu = ‘‘0‘‘
connect by prior a.submenu = a.menu‘
);
    -- Populate the record group with data.  
    v_ignore := POPULATE_GROUP(rg_emps);
    Ftree.Set_Tree_Property(HTREE, Ftree.RECORD_GROUP, rg_emps);
   
END;

 

6,到第5步form已经可以预览了,这一步的目的是对tree的一些操作的简单代码,可以自己摸索,本例到此为止。

创建Trigger: WHEN-TREE-NODE-SELECTED

Trigger内容:

/* Formatted on 2015/1/12 19:54:09 (QP5 v5.115.810.9015) */DECLARE   htree        ITEM;   node_value   VARCHAR2 (100);BEGIN   htree := FIND_ITEM (B.TEXT1);   --node_value := Ftree.Get_Tree_Node_Property(htree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);   --node_value := Ftree.Get_Tree_Node_Property(htree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_STATE);   --node_value := Ftree.Get_Tree_Node_Property(htree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_DEPTH);   node_value := Ftree.GET_TREE_NODE_PROPERTY (htree,:SYSTEM.TRIGGER_NODE,Ftree.NODE_VALUE);   /*   其中property有如下几种:  NODE_STATE:EXPANDED_NODE(扩展节点)  COLLAPSED_NODE(收缩节点)  LEAF_NODE(叶节点)--注:不能展开或收缩    NODE_DEPTH:既节点在树中的层级。    NODE_LABEL:节点的显示文本    NODE_ICON:节点的图标   NODE_VALUE:节点的值。   */   MESSAGE (Node: || node_value);--Message(‘Node:‘||node_value);END;

 

 

 

 

Thanks and Regards

技术分享

Form_Form Tree树形结构的开发(案例)