私はtodosのリストを持っており、それらに関連付けられたタグプロパティがあります。ビューには、「Sort By Tag」ボタンがあります。そのボタンを押すと、コレクションをタグでソートする必要があります。今は何も起こっていない。以下はコードです。どうしましたか?SproutCoreコレクションソート
In todos.js I have:
Todos.SortingView = SC.TemplateView.extend({
sortBinding: 'Todos.todoListController.sortTodos'
});
and in todoListController, I have:
sortTodos: function() {
Todos.store.find(Todos.Todo).sortProperty('tag');
}
and in the handlebars view I have:
{{#view Todos.SortingView id="stats"}}
{{#view SC.Button classBinding="isActive" target="Todos.todoListController" action="sortTodos"}}
Sort By Tag
{{/view}}
{{/view}}
{{#collection SC.TemplateCollectionView contentBinding="Todos.todoListController" itemClassBinding="content.isDone"}}
{{view Todos.MarkDoneView}} - Tag - {{content.tag}}
{{/collection}}
あなたのListControllerは何ですか? – hvgotcodes
Todos.todoListController = SC.ArrayController.create({ //空のアレイを有するアレイコントローラを初期化し コンテンツ:[]、 //機能sortTodos:関数(){ Todos.store.find(トドス.Todo).sortProperty( 'tag'); }、 //関数 }); –