Map Sencha Touch model hasMany association to List items - sencha-touch

I have a hasMany relationship between employee-favorites. I can get the store to populate the data structure, but my question is there a way to have the child element (the favorites in this case) be the items for the list item template.
I can use tpl for statement but then all the items are in one list item element. I need one per item element.

There is no out of the box solution for this. The only way to show associations, as you pointed out, is to use a custom tpl which loops through them.
This is because Lists are Store backed components, and stores currently only support 1 type of model.

Related

SiteFinity 7.1 custom content items and grouping

We have a list of faculty and units for a SiteFinity 7.1 site. We have these as custom content items in the site, because we are programming against them and building a few widgets around them.
However, we also have news about these faculty and units, and we'd like to use the existing news items in SiteFinity.
How do we easily tie faculty and units (custom content items) to news items (another content item baked into SiteFinity)? I wasn't sure if we create classifications that list faculty and units, and use these as the grouping mechanism? Or is there an easy way to tie two content items together? 
It kind of depends on how you're going to (or how you want to) display the data at the end. Here are a couple of different ways to achieve what you're after.
You're planning on using the stock News widget to display the content.
If this is true, using a custom taxonomy would be pretty easy in this case. Here's a video that outlines this method.
You're planning on displaying the news items in close proximity to one of the custom content types you've created.
In this case, adding a related data field to the custom type would allow you use related content items with widget templates.

Core Data and bindings - binding checkbox to result of many-to-many relationship

Core Data model
I have a many-to-many relationship between two of the principal entities; call them Item and Tag. There will be a large number of Documents. Each may have 0 to an arbitrary number of tags.
Each Item entity relevantly has an attribute called name, and a to-many relationship to Tag called tags. Each Tag entity relevantly has an attribute called name, and a to-many relationship to Item called items.
To display them, within the same window, I have: (i) an NSTableView (itemTableView), fed by an NSArrayController (itemArrayController), showing all Items; and (ii) an NSTableView (tagTableView), fed by a different NSArrayController (tagArrayController) showing all Lists.
tagTableView
In the tagTableView, the Table View is bound to tagArrayController, with controllerKey arrangedObjects.
There is only a single table column. The textfield in it is bound to Table Cell View, to model key path objectValue.name. That works so far; it displays all of the lists as expected, and sorts properly when I add a sort descriptor.
Everything has been set up using interface builder in Xcode.
The problem
I have added a checkbox into the tagTableView, in the same table column as the textfield. I am trying to implement two things:
The checkbox should be checked if the user has previously associated the Item with the relevant Tag. If not, the checkbox should be unchecked.
If the user checks an unchecked checkbox, I want to establish a relationship between the two; if the user unchecked a checked checkbox, I want to break that relationship.
The underlying behavior pattern is that the user will not necessarily have control over the tags and may not be able to create them. They are to choose from existing tags, and therefore should be able to see which ones exist, and be able to check/uncheck those that apply.
However, I can't see how to implement this.
Part solutions so far
I can see a possible way to do at least the first task programmatically, roughly along these lines:
Monitor tableViewSelectionDidChange for itemTableView
For a change, update the data source for tagTableView manually, and work out checkbox state by checking them for those Tags which relate to the Item entity that has just been selected, and otherwise unchecking them
However, this looks likely to add complexity, and ideally I would like to do this with bindings if possible.
I have reviewed the Apple Core Data and Bindings references, all the Cocoa books I have, stack overflow and I've also done extensive googling. I have found lots of similar questions (e.g. http://lists.apple.com/archives/cocoa-dev/2011/Mar/msg00164.html) but no answers.
I've also found a way that might work programmatically, but which seems to be like my idea above, at the expense of being able to use bindings (e.g. http://www.raywenderlich.com/14742/core-data-on-ios-5-tutorial-how-to-work-with-relations-and-predicates)
The only relevant question on this site -- Core-Data Check Box Cell with many-to-many data -- is not answered to a level that I can make use of.
It would seem to me that this should be a prime candidate for bindings. I should be able to ask the itemArrayController what Tags (if any) have a relation to its selected item, and then set the checkbox to ticked if it matches the relevant Tag, and unset it if it doesn't. I would expect I should be able to do this within the bindings for the checkbox itself, in interface builder. But I can't work out what model key path or binding to use, or what to set the cocoa bindings for the checkbox to. Am I missing something obvious? Thanks

How to add grid to Extjs Form and submit its data?

I am designing a highly complex data entry form using extjs 4.0. I am binding a model to my form.
Inside my model I am having a property say "Products" which represent the Product model. Now I want to show these products in Grid on my form Panel. User can add remove the products from the grid and save the form.
What is the best way to achieve this ?
If I understood you correctly you have a 1 to Many association of objects where the 1 side is loaded into a form for editing and the Many need to also be show but in a grid within the form.
The way I approached a similar design is by adding a gridpanel below the form. In my case there were other components so my grid was wrapped in a tabpanel. Similar to this example see form 5.
Now, what goes in the grid? Well I added a store representing my Many objects - or Products for your example. I setup a writer proxy for that store and added a roweditor plugin to the grid. The end result was an easy way for users to manage the relationships, edit properties of both parent and children objects all from one screen. I chose to have an autosync store for the Many store, but you dont have to. You can easily add a save button to the grid, or just bind the action to the parent's Save button.
Hope this get's your creative juices flowing :)
You could overwrite setValues(), getValues() methods of your form. Just add grid binding to the base methods. Note - no need to extend the form to create your own class. You could overwrite these functions right where you declare the form.
{
xtype: 'form',
setValues: function(){}
}
Hope this helped.

Silverlight Datagrid binding with Object with a List Property

I'm having trouble with some Silverlight functionality. My goal is to get some data from the database and display it in my grid. Sounds simple, however, there are 7 columns that are always going to be there.
The rest of the columns depends on the account. There could be 2 (called Actions) associated with a certain account, compared to another account that could have 5, and the action names can be completely different.
I have successfully been able to return a list of all the possible actions for the given account, and then adding the columns to the grid in the code bihind(VB), and I can bind my data to the grid for all the columns that
are already known. The way I store the item's actions, is a Property of type List. My problem is finding a way to iterate through the actions list of the Item object in order to bind those actions to the grid.
Any suggestions?
You can create extension that will create additional columns and bindings that will bind each value from list to column. Also you should create an additional Dependency Property which you'll bind
to your List.

Core data, NSArrayContainer Arraycontent of many arrays

I've got three entities in my application so far: tag, feed and story
A tag has got a to-many relationship to feeds and feeds has got a to-many relationship to story.
I've got an NSArrayController for each entity, one named tags, one named feeds and one named stories.
They all share the same 'managedObjectContext' which they get from the file's owner. the content set of the AC named feeds is bound to 'tags' controler key: selection, key path: feeds
I want the content set of the third array to be bound to all of the stories in all of the feeds in the selected tag: i tried to use the key path: "#unionOfArrays.stories" but couldn't get it to work.
Any idea how i would go about this?
First of all, there's one thing in your question that's inconsistent with getting something working:
They all share the same
'managedObjectContext' which they get
from the file's owner
When I set this up in IB, it just didn't work. You surely mean you bound the managedObjectContext to that of the App Delegate.
Assuming you want to see all the stories in the selected tag, here's a few mistakes you might have made in your setup.
1. Check Inverse Relationships
For all the relationships you mention, you need to set the inverse for each relationship.
For the one to many tags->feeds relationship, you'd have a to many relationship in the tags elements called "feeds", which you've described.
You'd also have a to one relationship in the feeds entity called "tag".
You'd select the inverse relationship as being feeds as shown below:
Single Feed Relationship http://img20.imageshack.us/img20/2557/tagsinglefeedrelationsh.jpg
2. Link Up Stories
You don't mention how you've created any of your Stories. Assuming you're not doing anything in code, I'd have 4 Array Controllers:
Tags
Feeds in Selected Tag
Stories in Selected Feed
All Stories in Selected Tag
If you just have a Stories Array Controller whose Content Set isn't bound to anything, you'll be creating stories effectively in a vacuum - they won't be linked to any feeds or tags, which might be why you're getting these errors.
3. Setup "Stories in Selected Tag" Controller
You need to set the Content Array, not the Content Set.
Bind the Content Array to the "Feeds in Selected Tag" Controller.
Key: arrangedObjects
Key Path: #unionOfArrays.stories
This sends the Key Path stories to every object in the "Feeds in Selected Tag" Controller, thus getting all the Stories in all the Feeds in the selected Tag.
4. Rock and Roll!
We're done. If you're really struggling getting this set up, let me know and I can post the link to the XIB file I've made.
You can try #distinctUnionOfSets.stories. All Core Data 1-n relationships are implemented as sets.