JQuery樹形外掛程式Dynatree的封裝對象

來源:互聯網
上載者:User

標籤:http   java   使用   os   io   cti   ar   代碼   

這是JQuery Dynatree外掛程式的封裝對象,做了些改進和增強,增加了右鍵菜單,以及相應事件等擴充
1. [代碼]MagicDTree的基本使用     

<SCRIPT type=text/javascript>
$(function(){
    var ctxMenu = $(‘#ctxMenu1‘);
    var tree = $(‘#tree1‘);
    tree.mac(‘dtree‘, {
        treeConfig: {
            title: Msg.region.allRegions,
            rootVisible: true
        },
        ctxMenu: ctxMenu,
        doInsert: function(dt, callback){
            var d = dt.data;
            d.level = d.level?d.level:0;
            var p = { level: 1, path: ‘/‘, parent: ‘root‘ };
            if(d.level>0){
                p.parent = d.key;
                p.level = d.level + 1;
                if(d.level==1){
                    p.path = ‘/‘+ d.key + ‘/‘;
                }else{
                    p.path = d.path + d.key + ‘/‘;
                }
                p.value = d.value;
            }
            App.open({
                action: ‘editRegion‘,
                title: Msg.region.add,
                modal: true,
                params: p
            }, function(dd){
                callback(dd);
                //dt.deactivate();
                //dt.activate();
            });
        },
        doUpdate: function(dt, callback){
            var d = dt.data;
            App.open({
                action: ‘editRegion‘,
                title: ‘Msg.region.edit‘,
                modal: true,
                params: d
            }, function(dd){
                callback(dd);
            });
        },
        doDelete: function(dt, callback){
            mac.confirm(‘Msg.confirm.message‘, function(){
                mac.alert(‘Delete is not allowed in this demo.‘)
//              var p = { id: dt.data.key, level: dt.data.level };
//              $.post(‘delete.php‘, p, function(data){
//                  var ro = mac.eval(data);
//                  if(ro.success){
//                      mac.alert(Msg.info.success, [ Msg.del ]);
//                      callback();
//                      var tx = tree.getNode(dt.data.parent);
//                      tx.activate();藝術字
//                  }else{http://www.huiyi8.com/yishuzi/?
//                      mac.alert(ro.data, ro.params);
//                  }
//              });
            }, [ ‘Msg.del‘ ]);
        },
        loader: {
            url: ‘/javascript/dtree/list.php‘,
            params: { key: ‘root‘ },
            autoLoad: true
        },
        onCtxMenu: function(el){
            var d = el.prop(‘dtnode‘).data;
            ctxMenu.enableContextMenuItems();
            if(!d.level){
                ctxMenu.disableContextMenuItems(‘update,delete‘);
            }
        }
    });
    $(‘.demoSource‘).val($(‘#demo‘).html());
    mac.setLanguage();
});
</SCRIPT>
 
<DIV id=tree1></DIV>
<UL id=ctxMenu1 class="ctxMenu">
<LI class="add item clear" action="insert"><SPAN ><SPAN class="icon icon-plus"></SPAN><SPAN>Add Region</SPAN> </SPAN></LI>
<LI class="edit item clear" action="update"><SPAN ><SPAN class="icon icon-pencil"></SPAN><SPAN>Edit Region</SPAN> </SPAN></LI>
<LI class="delete item clear" action="delete"><SPAN ><SPAN class="icon icon-minus"></SPAN><SPAN>Delete Region</SPAN> </SPAN></LI></UL>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.