3
votes

Sencha Fiddle

My API returns JSON object visible in Attachments.store.Attachments data. It seems to me that the structure consists of 4 models: AttachmentObject, AttachmentDef, AttachmentFile and AttachmentNote. I've defined them in the fiddle and associated each other using hasOne and hasMany. I've also created a simple grid and a form.

  1. In the grid I want to present attachment's name in the last column, but I can't access child nodes using dataIndex property. When passing only "attachmentDef" as dataIndex grid converts child to "[object Object]" string, which means the nested data is noticable by the grid. I've also tried to retrieve the name using renderer, but then sorting functionality is gone.

  2. API expects same JSON format in case of posting a new attachment. How to instantiate above models and bind chosen model fields (i.e. name and note) with form fields?

1

1 Answers

1
votes
  1. here's the fiddle with child nodes and sort: https://fiddle.sencha.com/#view/editor&fiddle/257b I've changed the store load and I've used 'templatecolumn' and 'widgetcolumn' to show data.

  2. the creation of a new attachment depends on how you'd like to make it work, I suppose you might want to call a specific ws (defined in attachment model) to create a new attachment and then reload the grid's store