/**  
 * @author Van  
 * @constructor createKnowledgeCategoryTree
 * @description this page is for konwledge/konwledgeMain.jsp
 * @date 2010-11-17
 * @since version 1.0 
 */

$package('itsm.knowledge');


itsm.knowledge.knowledgeTree=function(){
	
	
	return {
		
		/**
		 * 显示知识库分类树.
		 */
		showKnowledgeTree:function(treeDIV,selectNode){
			
			 $(treeDIV).jstree({
					json_data: {
						ajax: {
						  type:"post",
						  url : "event!getCategoryTree.action",
					      data: {'types': 'Knowledge'},
		                  dataType: 'json',
		                  cache:false
					 	}
					},
				"plugins" : [ "themes", "json_data", "ui", "crrm","dnd", "search", "types", "hotkeys"]
			})
			.bind('loaded.jstree', function(e,data){data.inst.open_all(-1);})
			.bind("select_node.jstree", function(e,data){
				selectNode(e,data);
			 });
		},
		/**
		 * 显示知识库分类.
		 */
		selectKnowledgeCategory:function(windowId,treeId,nameId,valueId){
			
			$(windowId).window('open');
			
			itsm.knowledge.knowledgeTree.showKnowledgeTree(treeId,function(e,data){
				
                 $(nameId).val(data.rslt.obj.attr('cname'));
                 $(valueId).val(data.rslt.obj.attr('cno'));
                 
				 $(windowId).window('close');
			});
			
		}
		
		
	}
	
}();

