Update Template in Kendo-Ui Listview

717 views Asked by At

I have a dynamic created listview. The schema of the datasource is also changing tempanding on the action in the application. So the schema also is dynamically created.

My problem is, I can not update the template.

My code is

        if (queryResultsFirstLoad) {

            queryResultsFirstLoad = false;


            e.view.element.find("#queryResultsViewUl").kendoMobileListView({
                template : '<a>' + listInnerHtml + '</a>',
                dataSource : kendo.data.DataSource.create(data),
                click : function(e) {
                    if (e.dataItem) {
                        queryResultItemClick(e);
                    }
                }
            });

        } else {


            $("#queryResultsViewUl").data("kendoMobileListView").setDataSource(data);
            var newTemplate = kendo.template(listInnerHtml);
            $("#queryResultsViewUl").html(newTemplate(data));



        }

It works fine when it is first time loaded. But when it is load the second time, I can not update the template of the listview.

1

There are 1 answers

0
Calipso On BEST ANSWER

I couldn't find a method which only changes the template.. Another option was destroying the kendoListView.. it works

            if (!queryResultsFirstLoad) {

                var listView = $("#queryResultsViewUl").data("kendoMobileListView");
                // detach events
                listView.destroy();             
            } else {

                queryResultsFirstLoad = false;

            }

            e.view.element.find("#queryResultsViewUl").kendoMobileListView({
                template : '<a>' + listInnerHtml + '</a>',
                dataSource : kendo.data.DataSource.create(data),
                click : function(e) {
                    if (e.dataItem) {
                        queryResultItemClick(e);
                    }
                }
            });