2013年10月30日 星期三

jsTree 功能, Demo 程式碼測試

jsTree Home: http://www.jstree.com/


// Judge the tree folder is opened or collapsed
// 1) select the tree container using jQuery and call '.jstree("is_open","#tree_list_ID")'
$("#xml_o").jstree("is_open" , "#1");



// To toggle the tree folder open or collapse
// 1) select the tree container using jQuery and call '.jstree("toggle_node","#tree_list_ID")'
$("#xml_o").jstree("toggle_node","#html_1");



// To select the tree list
// 1) select the tree container using jQuery and call '.jstree("select_node","#tree_list_ID")'
$("#xml_o").jstree("select_node","#1" )


// To deselect the tree list
// 1) select the tree container using jQuery and call '.jstree("deselect_node","#tree_list_ID")'
$("#xml_o").jstree("deselect_node","#1" );



// To rename the tree list
// 1) select the tree list first
// 2) select the tree container using jQuery and call '.jstree("rename")'
$("#xml_o").jstree("rename");



// To delete the tree list
// 1) select the tree list first
// 2) select the tree container using jQuery and call .jstree("remove")
$("#xml_o").jstree("remove");


// To refresh the tree
// 1) select the tree container using jQuery and call .jstree("refresh")
$("#xml_o").jstree("refresh" );


// To collapse all tree
// 1) select the tree container using jQuery and call .jstree("close_all")
$("#xml_s_matrix_1").jstree("close_all");


// To open all tree
// 1) select the tree container using jQuery and call .jstree("open_all")
$("#xml_s_matrix_1").jstree("open_all");

// To refresh node of the tree
// 1) select the tree container using jQuery and call .jstree("refresh","#node")
$("#xml_s_matrix_1").jstree("refresh","#8");

// To get *json
// 1) select the tree container using jQuery and call .jstree("get_json")
$("#xml_o").jstree("get_json" );

// This function returns an array of tree nodes converted back to JSON.
// 1) select the tree container using jQuery and call .jstree("get_json","node")
$("#xml_s_matrix_1").jstree("get_json","#1");

//Returns the title of a node.
// 1) select the tree container using jQuery and call .jstree("set_text","node")
$("#xml_s_matrix_1").jstree("get_text","#8"); get name


//Sets the title of a node.
// 1) select the tree container using jQuery and call .jstree("set_text","node", "text")
$("#xml_s_matrix_1").jstree("set_text","#8","123");

//Creates the DOM structure necessary for a new node.
$("#xml_s_matrix_1").jstree("create_node", "#8", "1234");
parent_id position




(*) JSON: JavaScript Object Notation.
JSON is syntax for storing and exchanging text information. Much like XML.

JSON is smaller than XML, and faster and easier to parse.

沒有留言:

張貼留言