HT for Web 属性面板手册

索引


概述

HT for Web提供了属性面板组件,该组件增强了ht.widget.PropertyView组件的展示及操作功能,提供了可视化的切换排序、过滤和分组的界面功能。

使用属性面板组件需要在引入ht.js核心库之后,再引入一个ht-propertypane.js的属性面板插件库。

属性面板组件

ht.widget.PropertyPane为属性面板类,其构造函数可传入ht.DataModel对象,其主要可配置属性和函数如下:

<!DOCTYPE html>
<html>
    <head>
        <title>PropertyPane</title>
        <meta charset="UTF-8">   
        <style>
            html, body {
                padding: 0px;
                margin: 0px;                
            }            
            .main {
                margin: 0px;
                padding: 0px;
                position: absolute;
                top: 0px;
                bottom: 0px;
                left: 0px;
                right: 0px;
            }
        </style>    

        <script src="../../../../lib/core/ht.js"></script> 
        <script src="../../../../lib/plugin/ht-propertypane.js"></script>   
        <script>
            function init(){                                                                
                dataModel = new ht.DataModel();
                tablePane = new ht.widget.TablePane(dataModel);
                propertyPane = new ht.widget.PropertyPane(dataModel);                    
                splitView = new ht.widget.SplitView(tablePane, propertyPane, 'h', 0.6);                                

                view = splitView.getView();
                view.className = 'main';
                document.body.appendChild(view);    
                window.addEventListener('resize', function (e) {
                    splitView.invalidate();
                }, false);   

                var attributes = [
                    {
                        name: 'id',
                        displayName: 'Id'                        
                    },                    
                    {
                        name: 'superClass',
                        displayName: 'Super Class',   
                        categoryName: 'Class',
                        getValue: function(data){
                            var superClass = data.getClass().superClass;
                            return superClass.getClassName ? superClass.getClassName() : 'Object';
                        }
                    },                    
                    {
                        name: 'className',
                        displayName: 'Class',
                        categoryName: 'Class'
                    },  
                    {
                        name: '_image',                        
                        displayName: 'Image',  
                        categoryName: 'Image',
                        accessType: 'field',
                        width: 110
                    },                             
                    {
                        name: 'icon',
                        displayName: 'icon',  
                        categoryName: 'Image',
                        width: 120,
                        enum: {
                            values: ['node_icon', 'edge_icon', 'group_icon', 'shape_icon', 'subGraph_icon', 'grid_icon'], 
                            icons: ['node_icon', 'edge_icon', 'group_icon', 'shape_icon', 'subGraph_icon', 'grid_icon']
                        }                        
                    }                                       
                ];

                tablePane.addColumns(attributes);
                propertyPane.addProperties(attributes);

                [ht.Data, ht.Node, ht.Edge, ht.Group, ht.Grid, ht.Shape, ht.SubGraph, ht.Grid].forEach(function(clazz){
                    data = new clazz();
                    dataModel.add(data);                    
                });
                dataModel.sm().ss(data);
            }


        </script>
    </head>
    <body onload="init();">
    </body>
</html>

欢迎交流 service@hightopo.com