我有以下问题。以下代码适用于 JS:
Application1.Trackers = function (params) {
var viewModel = {
dsTrackers: new DevExpress.data.DataSource({
store: Application1.db,
searchExpr: "Bezeichnung"
}),
searchString: ko.observable(''),
find: function () {
viewModel.showSearch(!viewModel.showSearch());
viewModel.searchString('');
},
showSearch: ko.observable(false),
};
ko.computed(function () {
return viewModel.searchString();
}).extend({
throttle: 500
}).subscribe(function (value) {
viewModel.dsTrackers.filter("Bezeichnung", "contains", value);
viewModel.dsTrackers.pageIndex(0);
viewModel.dsTrackers.load();
});
return viewModel;
};
在打字稿中,我尝试过这种方式,但这不起作用:
module MyExtremeApp {
export function Trackers(params: { id: any }) {
return {
dsTrackers: new DevExpress.data.DataSource({
store: MyGlobals.oTrackerManager.getTrackerCustomStore(),
searchExpr: "Bezeichnung"
}),
searchString: ko.observable(''),
find: function () {
this.showSearch(!this.showSearch());
this.searchString('');
},
showSearch: ko.observable(false),
};
ko.computed(() => {
return this.searchString();
}).extend({
throttle: 500
}).subscribe(function (value) {
this.dsTrackers.filter("Bezeichnung", "contains", value);
this.dsTrackers.pageIndex(0);
this.dsTrackers.load();
});
}
}
它永远不会跳转到 ko.computed()。有谁知道为什么不? 我是打字稿的新手
非常感谢。此致