Probably i'm very stupid, but i can't understand how to create component for my app like bosses_and_clerks from Demo.
Code from demo modified for my models - ends with JS error in callback -
view = this.getComponent('comp_name').getView();
ERR_MSG:
Uncaught TypeError: Cannot call method 'getView' of undefined
Ruby 2.1.0 - Rails 4.0.3 - ExtJS 4.2.2
Tutorial from Github too old and can't help
What i do wrong?
class Application < Netzke::Basepack::Viewport
include Netzke::Basepack::ItemPersistence
def configure(c)
super
c.items = [
layout: :border,
border: true,
id: :main_frame,
items: [
{ region: :west, width: 200, split: true, layout: :fit, items: [
{ region: :center, component: :countries }
]},
{ region: :center, split: true, layout: :fit, items: [
{region: :center, component: :provinces }
]},
{ region: :east, split: true, width: 400, layout: :fit, items: [
{region: :center, component: :cities }
]}
]
]
end
js_configure do |c|
c.layout = :fit
c.padding = 2
# Overriding initComponent
c.init_component = <<-JS
function(){
// calling superclass's initComponent
this.callParent();
// setting the 'rowclick' event
var view = this.getComponent('provinces').getView();
view.on('itemclick', function(view, record){
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
this.selectProvince({provicne_id: record.get('id')});
this.getComponent('cities').getStore().load();
}, this);
}
JS
end
component :provinces do |c|
c.klass = Provinces
#include PgGridTweaks
end
component :countries do | c |
c.klass = Countries
c.model = 'Country'
#include PgGridTweaks
end
component :cities do |c|
c.klass = Cities
c.model = "City"
#include PgGridTweaks
c.data_store = {auto_load: true}
c.scope = {:province_id => component_session[:selected_province_id]}
c.strong_default_attrs = {:province_id => component_session[:selected_province_id]}
end
# region selected
endpoint :select_province do | params, this |
component_session[:selected_province_id] = params[:province_id]
end
Увы, английский плох, много хуже чме когда начинал его изучать, но в русской ветке вообще тищина ;)