Thread Rating:
  • 356 Vote(s) - 2.76 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ツリー構造について
07-08-2014, 09:24 AM,
#4
RE: ツリー構造について
romさん
サンプルソース作成したので、合わせて確認してみてください。
Code:
||++  TreeNode拡張
||++  TreeNodeに階層フィールドを追加
{define-class public ExTreeNode {inherits DefaultTreeNode}
  field public node-level:int  {constructor public {default
                          ...
                      }
    {construct-super
        {splice ...}
    }
  }
}||++  TreeControl生成
{TreeControl
    data-model =
        {TreeModel
            root =
                {ExTreeNode node-data="Food",
                    {ExTreeNode node-data="Fruit",
                        {ExTreeNode node-data="Apples",
                            {ExTreeNode node-data="Macintosh"},
                            {ExTreeNode node-data="Cortland"},
                            {ExTreeNode node-data="Gala"},
                            {ExTreeNode node-data="Delicious"}
                        },
                        {ExTreeNode node-data="Oranges"}
                    },
                    {ExTreeNode node-data="Vegetables",
                        {ExTreeNode node-data="Squash"},
                        {ExTreeNode node-data="Tomatoes"},
                        {ExTreeNode node-data="Cucumbers"}
                    }
                }
        },    ||++ tree-item-creation-procに階層値を設定
    tree-item-creation-proc ={proc {node:TreeNode}:TreeItem
                                 {type-switch node
                                  case et:ExTreeNode do
                                     {if et.parent == null then
                                         set et.node-level = 1
                                      else
                                         def par = et.parent
                                         {type-switch et.parent
                                          case etp:ExTreeNode do
                                             set et.node-level = etp.node-level+1
                                         }
                                     }
                                 }
                                 {return {DefaultTreeItem node}}
                             },    ||++ アクションイベント
    {on Action at tc:TreeControl do
        {type-switch tc.current-node
         case et:ExTreeNode do
            {popup-message et.node-level&"階層です。"}
        }
    }
}



Messages In This Thread
ツリー構造について - by rom - 07-02-2014, 10:54 AM
RE: ツリー構造について - by rom - 07-02-2014, 11:28 AM
RE: ツリー構造について - by e.kou - 07-04-2014, 02:50 PM
RE: ツリー構造について - by e.kou - 07-08-2014, 09:24 AM
RE: ツリー構造について - by umemura - 07-08-2014, 10:51 AM
RE: ツリー構造について - by rom - 07-08-2014, 02:55 PM
Forum Jump:


Users browsing this thread:
5 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('1095')