grid

grid

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  78 Posts :: 0 Stories :: 62 Comments :: 0 Trackbacks

#

菜单         
                   
参考示例菜单
           
           

创建菜单         

<ul id="menu1" class="mini-menubar" style="width:100%;" 
    url="../data/listMenu.txt" idField="id" parentField="pid">
</ul>

           

url数据格式

[
    { id: "1", text: "文件(F)"},        
    '-',
    { id: "2", text: "新建", iconCls: "icon-new", pid: "1"},    
    { id: "3", text: "文件", pid: "2"},
    { id: "4", text: "文件夹", pid: "2"},        
    { id: "5", text: "打开", iconCls: "icon-folderopen", pid: "1"},
    { id: "6", text: "保存", pid: "1"},
    { id: "7", text: "关闭", pid: "1"},
        
    { id: "8", text: "编辑(E)"},
    { id: "9", text: "剪切", iconCls: "icon-cut", pid: "8"},
    { id: "10", text: "复制", pid: "8"},
    { id: "11", text: "粘贴", pid: "8"},
        
    { id: "12", text: "查看(V)"},
    { id: "13", text: "帮助(H)", iconCls: "icon-help"}
]
        
posted @ 2012-12-19 16:25 nikofan 阅读(1593) | 评论 (0)编辑 收藏

ToolBar:工具栏           
                           

参考示例ToolBar:工具栏
                   

创建工具栏      

<div class="mini-toolbar">
    <a class="mini-button" iconCls="icon-add">增加</a>
    <a class="mini-button" iconCls="icon-edit">修改</a>
    <a class="mini-button" iconCls="icon-remove">删除</a>
    <span class="separator"></span>
    <a class="mini-button" plain="true">增加</a>
    <a class="mini-button" plain="true">修改</a>
    <a class="mini-button" plain="true">删除</a>
    <span class="separator"></span>
    <input class="mini-textbox" />   
    <a class="mini-button" plain="true">查询</a>
</div>

           

复杂工具栏

<div id="toolbar1" class="mini-toolbar" style="padding:2px;">
    <table style="width:100%;">
        <tr>
        <td style="width:100%;">
            <a class="mini-menubutton" plain="true" menu="#popupMenu">文件</a>
            <a class="mini-button" iconCls="icon-addfolder" plain="true" enabled="false">增加</a>
            <a class="mini-button" iconCls="icon-edit" plain="true">修改</a>
            <a class="mini-button" iconCls="icon-remove" plain="true">删除</a>
            <span class="separator"></span>
            <a class="mini-button" iconCls="icon-reload" plain="true">刷新</a>
            <a class="mini-button" iconCls="icon-download" plain="true">下载</a>
        </td>
        <td style="white-space:nowrap;"><label style="font-family:Verdana;">Filter by: </label>
            <input class="mini-textbox" />
            </td>
        </tr>
    </table>
</div>
posted @ 2012-12-18 17:03 nikofan 阅读(2737) | 评论 (0)编辑 收藏

TreeGrid:节点拖拽
            
                     

参考示例: TreeGrid:节点拖拽    
                

创建代码    

<div id="treegrid1" class="mini-treegrid" style="width:600px;height:280px;"     
    url="../data/tasks.txt" showTreeIcon="true" 
    treeColumn="taskname" idField="UID" parentField="ParentTaskUID" resultAsTree="false"
    allowDrag="true" allowDrop="true">
    <div property="columns">
        <div type="indexcolumn"></div>
        <div name="taskname" field="Name" width="200">任务名称</div>
        <div field="Duration" width="100">工期</div>
        <div field="Start" width="100" dateFormat="yyyy-MM-dd">开始日期</div>
        <div field="Finish" width="100" dateFormat="yyyy-MM-dd">完成日期</div>
    </div>
</div>                     
  • allowDrag:允许拖拽节点               
  • allowDrop:允许投放节点
posted @ 2012-12-17 20:27 nikofan 阅读(1652) | 评论 (0)编辑 收藏

TreeGrid:绘制单元格
            
            
参考示例: TreeGrid:绘制单元格    
               
          

监听处理"drawcell"事件         

使用"drawcell"事件,可以自定义单元格内容、样式、行样式等。

function onDrawCell(e){
    var node = e.node,
        column = e.column,
        field = e.field,
        value = e.value;

    //格式化日期
    if (field == "Finish") {
        if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy年MM月dd日");
    }
    //工期
    if (field == "Duration") {
        e.cellHtml = value + "天";
    }
    //进度
    if (field == "PercentComplete") {
        e.cellHtml = '<div class="progressbar">'
                        + '<div class="progressbar-percent" style="width:' + value + '%;"></div>'
                        + '<div class="progressbar-label">' + value + '%</div>'
                    +'</div>';
    }
};
posted @ 2012-12-14 15:58 nikofan 阅读(2729) | 评论 (2)编辑 收藏

TreeGrid:懒加载
            
            
参考示例TreeGrid:懒加载    
                           

创建代码

<div id="treegrid1" class="mini-treegrid" style="width:600px;height:250px;"     
    url="../data/TreeService.aspx?method=LoadNodes" showTreeIcon="true" textField="text" idField="id" 
    treeColumn="filename" onbeforeload="onBeforeTreeLoad">
    <div property="columns">
        <div name="filename" field="name" width="150">名称</div>
        <div field="type" width="100">类型</div>
        <div field="size" width="100" dateFormat="yyyy-MM-dd">大小</div>
        <div field="createdate" width="100" dateFormat="yyyy-MM-dd">创建日期</div>
    </div>
</div>
          

服务端返回数据

[{
    id: "form",
    text: "Form",
    ......
    isLeaf: false,                            //是否叶子节点:+和-号
    expanded: false                            //节点处于收缩状态
},
......
]
其中,isLeft 说明此节点是否有下一级节点。expanded 表示此节点处于折叠状态。
            
           

懒加载事件         

当用户点击"+"图标时,会自动加载下一级节点,此时会把当前节点id传递到后台,也可以拦截加载事件,增加额外属性:

function onBeforeTreeLoad(e) {
    var tree = e.sender;    //树控件
    var node = e.node;      //当前节点
    var params = e.params;  //参数对象

    //可以传递自定义的属性
    params.myField = "123"; //后台:request对象获取"myField"
}

           

服务端处理          

服务端通过request获取"id"属性后,加载此节点的下一级节点数组,并通过JSON返回。

String id = Request["id"];
if (String.IsNullOrEmpty(id)) id = "-1";

//获取下一级节点
String sql = "select * from plus_file where pid = '" + id + "' order by updatedate";
ArrayList folders = DBUtil.Select(sql);

//判断节点,是否有子节点。如果有,则处理isLeaf和expanded。
for (int i = 0, l = folders.Count; i < l; i++)
{
    Hashtable node = (Hashtable)folders[i];
    String nodeId = node["id"].ToString();

    String sql2 = "select * from plus_file where pid = '" + nodeId + "' order by updatedate";
    ArrayList nodes = DBUtil.Select(sql2);

    if (nodes.Count > 0)
    {
        node["isLeaf"] = false;
        node["expanded"] = false;
    }

}

//返回JSON
String json = PluSoft.Utils.JSON.Encode(folders);
Response.Write(json);
posted @ 2012-12-13 16:56 nikofan 阅读(2820) | 评论 (0)编辑 收藏

     摘要: 普加甘特图是WEB甘特图首选解决方案。适用于构建项目管理、生产排程等进度计划管理软件。支持任意开发平台和数据库。它是JavaScript开发的,无需安装插件,跨浏览器运行。  阅读全文
posted @ 2012-12-13 10:01 nikofan 阅读(5159) | 评论 (1)编辑 收藏

TreeGrid
            
            
参考示例: TreeGrid    
                
           

创建TreeGrid

<div id="treegrid1" class="mini-treegrid" style="width:600px;height:280px;"     
    url="../data/tasks.txt" showTreeIcon="true" 
    treeColumn="taskname" idField="UID" parentField="ParentTaskUID" resultAsTree="false">
    <div property="columns">
        <div type="indexcolumn"></div>
        <div name="taskname" field="Name" width="200">任务名称</div>
        <div field="Duration" width="100">工期</div>
        <div field="Start" width="100" dateFormat="yyyy-MM-dd">开始日期</div>
        <div field="Finish" width="100" dateFormat="yyyy-MM-dd">完成日期</div>
    </div>
</div>           

注意:idField、parentField、resultAsTree属性。


       
           

数据结构:列表         

通过url返回的数据结构如下:

[
    {id: "base", text: "Base", expanded: false},    
    {id: "ajax", text: "Ajax", pid: "base"},
    {id: "json", text: "JSON", pid: "base"},
    ......
]
其中,id和pid对应父子关系。
           

Columns列配置         

TreeGrid的列配置,跟DataGrid类似。参考如下:

posted @ 2012-12-12 17:04 nikofan 阅读(3818) | 评论 (0)编辑 收藏

过滤树           
                   

参考示过滤树


                       

filter节点过滤          

tree.filter(function (node) {
    var text = node.text ? node.text.toLowerCase() : "";
    if (text.indexOf(key) != -1) {
        return true;
    }
});
          

clearFilter取消过滤         

tree.clearFilter();
posted @ 2012-12-11 16:02 nikofan 阅读(1599) | 评论 (0)编辑 收藏

树右键菜单
                   

参考示例树右键菜单

      

           

一:创建ContextMenu     

<ul id="treeMenu" class="mini-contextmenu"  onbeforeopen="onBeforeOpen">        
    <li iconCls="icon-move" onclick="onMoveNode">移动节点</li>
    <li class="separator"></li>
    <li>
        <span iconCls="icon-add">新增节点</span>
        <ul>
            <li onclick="onAddBefore">插入节点前</li>                
            <li onclick="onAddAfter">插入节点后</li>    
            <li onclick="onAddNode">插入子节点</li>                 
        </ul>
    </li>
    <li name="edit" iconCls="icon-edit" onclick="onEditNode">编辑节点</li>
    <li name="remove" iconCls="icon-remove" onclick="onRemoveNode">删除节点</li>        
</ul>

           

二:设置contextmenu   

<ul id="tree1" class="mini-tree" url="../data/tree.txt" style="width:200px;padding:5px;" 
    showTreeIcon="true" textField="text" idField="id" 
    contextMenu="#treeMenu">        
</ul>

          

三:监听beforeopen事件   

function onBeforeOpen(e) {
    var menu = e.sender;
    var tree = mini.get("tree1");

    var node = tree.getSelectedNode();
    if (!node) {
        e.cancel = true;
    }
    if (node && node.text == "Base") {
        e.cancel = true;
        //阻止浏览器默认右键菜单
        e.htmlEvent.preventDefault();
        return;
    }

    ////////////////////////////////
    var editItem = mini.getbyName("edit", menu);
    var removeItem = mini.getbyName("remove", menu);
    editItem.show();
    removeItem.enable();

    if (node.id == "forms") {
        editItem.hide();
    }
    if (node.id == "lists") {
        removeItem.disable();
    }
}





       

           
       

   
posted @ 2012-12-10 16:24 nikofan 阅读(2254) | 评论 (0)编辑 收藏

自定义节点
                       

参考示例自定义节点


                       

创建代码         

<ul id="tree1" class="mini-tree" url="../data/tree.txt" style="width:200px;padding:5px;" 
    showTreeIcon="true" textField="text" idField="id" 
    ondrawnode="onDrawNode" showCheckBox="true">        
</ul>           

此时,我们监听了“drawnode”事件。


           

drawnode 事件         

function onDrawNode(e) {
    var tree = e.sender;
    var node = e.node;

    var hasChildren = tree.hasChildren(node);

    //所有子节点加上超链接
    if (hasChildren == false) {
        e.nodeHtml = '<a href="http://www.miniui.com/api/' + node.id + '.html" target="_blank">' + node.text + '</a>';
    }

    //父节点高亮显示;子节点斜线、蓝色、下划线显示
    if (hasChildren == true) {
        e.nodeStyle = 'font-weight:bold;';
    } else {
        e.nodeStyle = "font-style:italic;"; //nodeStyle
        e.nodeCls = "blueColor";            //nodeCls
    }

    //修改默认的父子节点图标
    if (hasChildren == true) {
        e.iconCls = "folder";
    } else {
        e.iconCls = "file";
    }

    //父节点的CheckBox全部隐藏
    if (hasChildren == true) {
        e.showCheckBox = false;
    }
}

   
Note:   
  1. 文本内容(nodeHtml):所有子节点加上超链接   
  2. 节点样式(nodeStyle/nodeCls):父节点高亮显示;子节点斜线、蓝色、下划线显示     
  3. 节点图片(iconCls):修改默认的父子节点图标           
  4. 隐藏CheckBox(showCheckBox):父节点的CheckBox全部隐藏           
  5. 开发者可以扩展节点判断条件,对文本、样式、图标、CheckBox等做任意自定义.
posted @ 2012-12-07 16:21 nikofan 阅读(2771) | 评论 (0)编辑 收藏

仅列出标题
共8页: 上一页 1 2 3 4 5 6 7 8 下一页