Skip to content

Instantly share code, notes, and snippets.

@mxgrn
Created September 24, 2009 18:57
Show Gist options
  • Save mxgrn/192957 to your computer and use it in GitHub Desktop.
Save mxgrn/192957 to your computer and use it in GitHub Desktop.
class Netzke::TreePanel < Netzke::Base
api :get_children
def self.js_base_class
"Ext.tree.TreePanel"
end
def self.js_extend_properties
{
:root => {:text => '/', :id => 'source'}
}
end
def js_config
super.deep_merge({
:loader => {:data_url => id_name+"__get_children".l}
})
end
def get_children(params)
klass = config[:data_class_name].constantize
node = params[:node] == 'source' ? klass.find_by_parent_id(nil) : klass.find(params[:node].to_i)
node.children.map{|n| {:text => n.name, :id => n.id}}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment