KnockoutJS ObservableArray data grouping

后端 未结 3 1382
鱼传尺愫
鱼传尺愫 2020-12-05 08:06

Does KnockoutJS have a feature whereas I could take something like:

    var myArray = ko.observableArray([
      { name: \"Jimmy\", type: \"Friend\" },
              


        
3条回答
  •  臣服心动
    2020-12-05 09:01

    Just want to add to this that if you call this .distinct() method twice (like maybe from a computed observable), you'll get the indexes and associated computed function called twice - rinse and repeat and you've got a performance problem on your hands.

    To sort this out, add this line near the top of the function:

    if (target.index && target.index[prop]) return target; //Group by already set up, bail out.
    

提交回复
热议问题