2011-01-08 10 views
1

は、ここに私のScrollViewです:カスタムListViewの行、できなくなった行を選択

middle: SC.ScrollView.design({ 
    layout: { top: 36, bottom: 32, left: 0, right: 0 }, 
    backgroundColor: '#ccc', 

    contentView: SC.ListView.design({ 
    contentBinding: 'Spanish.wordsController.arrangedObjects', 
    selectionBinding: 'Spanish.wordsController.selection', 
    contentValueKey: "word", 
    contentDisplayProperties: 'word english'.w(), 
    selectOnMouseDown: YES, 

    exampleView: Spanish.CustomListItemView 

    }) 
}) 

、ここでは私のカスタムリストビューの行です:

Spanish.CustomListItemView = SC.View.extend({ 
    render: function(context, firstTime){ 
    var content = this.get('content'); 

    var word = content.get('word'); 
    var english = content.get('english'); 

    context = context.begin().push(' %@ (%@)'.fmt(word,english)).end(); 
    return sc_super(); 
    } 
}); 

上記の作品は、私はもはやできることを除いて、予想通りビューを選択します。私が "exampleView:Spanish.CustomListItemView"をコメントアウトすると、私は行を選択できますが、もはや適切にフォーマットされていません。 exampleViewを使用しても行を選択できないのはなぜですか?

答えて

3

代わりにSC.ListItemViewをサブクラス化してください。

return sc_super();行を削除します。

変更context = context.begin().push(' %@ (%@)'.fmt(word,english)).end();行には:

context.push(' %@ (%@)'.fmt(word,english)); 

今では動作するはずです。

+0

作品を間違ったクラスをサブクラス化して.ListItemView – LDK

0

IRCのヘルプを取得した後、私は問題を修正し、次の変更を加えた:

Spanish.CustomListItemView = SC.ListItemView.extend({ 
    render: function(context, firstTime){ 
    var content = this.get('content'); 

    var word = content.get('word'); 
    var english = content.get('english'); 

    context.push(' %@ (%@)'.fmt(word,english)); 
    } 

}); 

私はSCからサブクラス化する(最初の行に注意してください)あなたの提案と

関連する問題