private def get_tree(rights, parent) data = Array.new rights.each { |right| if !right.leaf? if data.empty? data = [{"text" => right.show_name,"id" => right.id, "cls" => "folder" ,"leaf" => false, :expanded => true, "children" => get_tree(right.children,right) }] else data.concat([{"text" => right.show_name,"id" => right.id, "cls" => "folder" ,"leaf" => false, :expanded => true, "children" => get_tree(right.children,right)}]) end else data.concat([{"text" => right.show_name,"id" => right.id,"cls" => "file","leaf" => true}]) end } return data #data end