javascript - Change template for Kendo Mobile ListView on setDataSource? -
i changing datasource using setdatasource method, need change template too. changing template dynamically doesn't seems work though.
below have , jsfiddle here: http://jsfiddle.net/mfsup. notice doesn't change "template 2" in "onfilter" event when clicking on button group. bug or doing wrong?
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() });
the following should work:
lv.template = kendo.template("<li data-uid='#=uid#'>" + (this.selectedindex == 0 ? $("#stages_listview_template1").html() : $("#stages_listview_template2").html() ) + "</li>");
Comments
Post a Comment