[英]Change template for Kendo Mobile ListView on setDataSource?
我正在使用setDataSource
方法更改数据源,但也需要更改模板。 动态更改模板似乎不起作用。
下面是我所拥有的,jsFiddle 在这里: http : //jsfiddle.net/MfSup 。 请注意,单击按钮组时,它不会在onFilter
事件中更改为“模板 2”。 这是一个错误还是我做错了?
new kendo.mobile.Application();
var ds1 = new kendo.data.DataSource({
data: [{
stagename: "ds1 A",
b: "1b"
}, {
stagename: "ds1 B",
b: "2b"
}]
});
var ds2 = new kendo.data.DataSource({
data: [{
stagename: "ds2 A",
b: "1b"
}, {
stagename: "ds2 B",
b: "2b"
}]
});
var onFilter = function (e) {
var lv = $("#stages_listview")
.data('kendoMobileListView');
//CHANGE TEMPLATE DOESN'T WORK
lv.options.template = this.selectedIndex == 0
? $("#stages_listview_template1").html()
: $("#stages_listview_template2").html();
lv.setDataSource(this.selectedIndex == 0 ? ds1 : ds2);
};
$("#stages_listview").kendoMobileListView({
dataSource: ds1,
template: $("#stages_listview_template1").html()
});
以下应该工作:
lv.template = kendo.template("<li data-uid='#=uid#'>" +
(this.selectedIndex == 0 ?
$("#stages_listview_template1").html() :
$("#stages_listview_template2").html()
) +
"</li>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.