我正在开发一个使用jQuery easy ui
的项目我实现了树节点,但我遇到了问题。我想使用拖放功能,但我无法生成正确的json字符串。
这就是我的全部。 这些数据来自数据库:
<?php
$array = array( 0 => array(
"id" => 1,
"text" => "Root Dir",
"parent" => 0
),
1 => array(
"id" => 2,
"text" => "Folder one",
"parent" => 1
),
2 => array(
"id" => 3,
"text" => "Folder two",
"parent" => 2
),
3 => array(
"id" => 4,
"text" => "File",
"parent" => 3
)
);
?>
最终输出应该如下所示
<?php
$array = array(
"id" => 1,
"text" => "Root Dir",
"children" => array(
"id" => 2,
"text" => "Folder one",
"children" => array(
"id" => 3,
"text" => "Folder one",
"children" => array(
"id" => 4,
"text" => "File"
)
)
)
);
print json_encode( $array );
?>
如果需要,我愿意调整数据库设计。