Dynamic load of a form with nested attributes

34 views
Skip to first unread message

Dmytro

unread,
Dec 19, 2013, 2:01:55 AM12/19/13
to net...@googlegroups.com
Hi,

I have 2 models with one to many association.

Model is displayed on the left on a grid, when I click on the item in a grid I want to load record from the same model in a form on the right.

Quite similar to how it's shown here  https://gist.github.com/nomadcoder/1135040

Model has one to many association. I am using double underscore '__' for association. 

When I load this form with specific record (i.e. 'static' record) all works OK, but for dynamic, it shows 'NaN'.

Do I understand correctly below code this.getComponent('submission_info').loadRecord(record); only loads record itself, but does not load associated model(s). 

Any idea how to get associations loaded?

Thank you,
Dmytro

Here're snippets of my models and form.

class Product < ActiveRecord::Base
  has_many :feed_submissions
...

class FeedSubmission < ActiveRecord::Base
  belongs_to :product
...

class SubmissionsScreen < Netzke::Base
 def configure(c)
    super
    c.layout = :border
    c.items = [
      { netzke_component: :submissions_grid, region: :west, width: 500 },
      { netzke_component: :submission_info, region: :center, split: true },
    ]
  end

js_configure do |c|
    c.init_component = <<-JS
      function(){
        this.callParent();

        var view = this.getComponent('submissions_grid').getView();
        view.on('itemclick', function(view, record){
          this.selectFeed({feed_id: record.get('id')});
          this.getComponent('submission_info').loadRecord(record);
        }, this);
      }
    JS
  end
end

In a left grid I have:

    c.columns = [                 
                 { name: :product__item_name,
                   :nested_attribute => true
                 },

In the right form I have:

    c.items = [
               { 
                 name: :product__item_name,
                 :nested_attribute => true
               },





Reply all
Reply to author
Forward
0 new messages