我是WPF的新手,我在尝试使用自定义排序对CollectionViewSource进行排序时遇到了困难.情况如下:
我有一个使用参数调用的SearchView,它变成了它的datacontext,如下所示:
mainView.SetGlobalOverlay(New SearchView With {.DataContext = interventionViewModel})
Run Code Online (Sandbox Code Playgroud)
在SearchView.xaml中,然后我将CollectionViewSource绑定到集合:
<CollectionViewSource x:Key="UnitsCollection"
Filter="UnitsCollection_Filter"
Source="{Binding Path=Units}" />
Run Code Online (Sandbox Code Playgroud)
现在,我已经在另一个共享类中实现了IComparer接口.此比较器用于源代码中其他位置的ListCollectionView,并且工作正常.现在,我如何在CollectionViewSource上重用这个比较器?
我使用这里的开发工具包开始了一个项目:https://github.com/datatypevoid/ng2-mean-webpack.一切似乎工作得很好,除非我创建一个带有参数属性的新类(如官方的Typescript文档中所示:https://www.typescriptlang.org/docs/handbook/classes.html ),我收到错误控制台中的消息说:
ORIGINAL EXCEPTION: No provider for Number!
Run Code Online (Sandbox Code Playgroud)
这是我的班级:
@Component({
selector: 'grid-tile',
template: require('./grid-tile.component.html'),
styleUrls: [require('!style!css!sass!./grid-tile.component.scss')],
providers: [],
directives: [],
pipes: []
})
export class GridTile extends Tile {
constructor(private x:number, private y: number) {
super();
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我创建实例的方法:
var tile = new GridTile(3,4);
tiles.push(tile);
Run Code Online (Sandbox Code Playgroud)
我非常希望在进一步开发的过程中找到解决这个问题的方法.我已经按照Angular2 Tour of Heroes教程和参数属性似乎工作正常,所以我想知道它是否与开发工具包有关或者只是我正在传递的东西..我对Angular2全新所以这可能是我的错误.谢谢您的帮助.
我是Magento的新手,我正试图弄清楚如何过滤一系列产品.情况就是这样:我有一个产品有'样式',这是产品的属性(样式的例子:黄铜).我需要获得所有其他具有"黄铜"风格的产品.
我做了一些研究并发现了addFieldToFilter()方法,但它似乎没有工作(或者,很可能,我没有正确使用它):
$same_style_collection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter(array(array('attribute' => 'name', 'like' => 'brass')));
Run Code Online (Sandbox Code Playgroud)
谁能帮我?这将不胜感激.