2016-08-30 7 views
0

私はcodeigniterとjsonを使用してデータベースから組織構造を作成するタスクを持っています。私には制約があります。スクリプトは機能していません。codeigniterとjsonを使用して組織構造を作成する方法

作成する方法はありますか?

これは私のデータベース(団体)である:

- table_org 
 
id urutan  name  title 
 
1  1  aaaa  Head of Logistic 
 
2  2  bbbbbb  Division Logistic 
 
3  3  ccccccc Staff/Employees, etc...

View : 
 

 
<body>  
 
    <div id="people"></div> 
 
    <script type="text/ecmascript"> 
 
\t 
 
\t \t var readUrl = "http://localhost/Codeg/struktur_org/"; 
 
\t 
 
\t \t $.getJSON(readUrl, function(people) { \t \t 
 
\t \t \t $('#people').getOrgChart({ 
 
\t \t \t \t theme: "helen", 
 
\t \t \t \t primaryColumns: ["name", "title"], 
 
\t \t \t \t imageColumn: "image", 
 
\t \t \t \t linkType: "M", 
 
\t \t \t \t editable: false, 
 
\t \t \t \t dataSource: people 
 
\t \t \t }); 
 
\t \t }); 
 
    </script> \t 
 
</body>

Controller : 
 

 
<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
 
//we need to call PHP's session object to access it through CI 
 

 
class Struktur_org extends CI_Controller { 
 

 
\t function __construct() 
 
\t { 
 
\t \t parent::__construct(); 
 
\t \t $this->load->model('struktur_model'); 
 
\t } 
 
\t 
 
\t public function index()//may be index() or something else.Rename this funciton name as yours 
 
\t { 
 
\t \t echo json_encode($this->struktur_model->getMember()); 
 
\t \t $this->load->view('struktur_org'); 
 
\t } 
 

 
}

Model : 
 

 
<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
 

 
class Struktur_model extends CI_Model { 
 

 
\t function __construct() 
 
    { 
 
\t \t parent::__construct(); 
 
\t } 
 
\t 
 
\t function getMember(){ 
 
\t \t 
 
     $query = $this->db->get('org'); 
 
     return $query; 
 
    } 
 
}

答えて

0

ヨール第2列はparrent IDであるべきです。ここでは例がある

- table_org 
 
id urutan  name  title 
 
1  null  aaaa  Head of Logistic 
 
2  1  bbbbbb  Division Logistic 
 
3  1  ccccccc Staff/Employees, etc...

関連する問題