View Full Version : many-to-many-relation in a grid with MVC-architecture

14 Nov 2012, 5:08 AM
Hello guys,

I have a grid with a model and a store that shows more or less a table in my database.
Know I have the problem, that this table or this view has a many-to-many-relation to another table, that should be shown in the grid.

To be exact:
table: item (id, name, desc, ...)
table: datasheet (id, blob, datatype, ...)
table: nm_item_datasheet (item_id, datasheet_id)

In my grid I want to show all datasheets in an actioncolumn as ActionColumnItems. On click the items should appear in a new window/tab.

So what do I have to do with the model, if I don't know how much datasheets will be there? And after that, how do I manage my view with the same problem?

Does anyone has some experiences with this?
Thanks a lot,

James Goddard
14 Nov 2012, 5:47 AM
Create 2 models one for item and another for datasheet. In your item modal add a "has many" assocation to the datasheet model.

Pass the item store to your grid and when you hit the action column pass record.datasheets() to your new window.

15 Nov 2012, 4:16 AM
This might help, although my chef told me yesterday not to use a database for the files.
But thanks, I think I will have to use the functionality in the future.

Best regards,