顯示具有 tree 標籤的文章。 顯示所有文章
顯示具有 tree 標籤的文章。 顯示所有文章

2009年7月21日 星期二

使用mptt來建構treeview

  1. 下載mptt
  2. 修正mptt在執行django1.0下所發生的錯誤
  3. 使用範例如下

3.1在model.py


from django.db import models

import mptt

class Category(models.Model):
name = models.CharField(max_length=50)
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')

def __unicode__(self):
return self.name

mptt.register(Category)

3.2執行snycdb

3.3輸入資料顯示結果

2009年7月19日 星期日

如何把分解結構用Tree view的方式顯示在html上


像一些WBS或是RBS等都需要利用Tree view的方式來顯示,顯示的內容如右。而在WEB GUI上一定會使用到Java script來顯示,可以使用jQuery的方式來作為顯示。

參考資料:http://www.hyperthot.com/pm_wbs_banquet.gif


jQuery的規則

首先是利用ul與li等來表示階層的概念,而第一的ul則class="treeview" id="tree"接下來再來設定各li的屬性如右圖所示。

而id則有四個要設定分別為main,sidetree,sidetreecontrol,tree