Question

I use kendo ui grid which allows templates to be used for rendering rows. It uses KO Template engine which expects template to be in tag, however I want to externalize the template and use Durandal Compose plugin... any idea how to hook it easily?

Was it helpful?

Solution

Problem is loading the template async/ externally. This is done by durandal's compose binding for normal view. kendo template doesn't support this. my solution for now is to load the template via compose binding and let kendo grid use it. In fact I am using kendo knockout, which supports knockout templates in kendo grid. so I don't have to write javascript in html (rowTemplate: kendo.template($("#rowTemplate").html())).

The only problem with this is, if I load the grid via another template, the compose for row binding cannot be inside that same template. It should be like

<html>
  <div data-bind="compose:{view:rowTemplateFromServer}"></div>
  <div data-bind="compose:{view:templateWithKendoGridBindinh}"></div>
</html>

This is not good for maintenance or my next gen devs.... I think i have to extend knockout kendo to use durandal compose binding. (knockoutkendo does support external template but its not working under durandal or jquery 9)


Fixed:

I have modified ExternalTemplateSource.js from KoExternalTemplate library to use Durandal's viewLocator instead of using infuser, now I can use kendo grid nicely without any issue (mentioned above). The getTemplate function in ExternalTemplateSource.js looks like below now:

getTemplate: function () {
  var self = this;
  viewLocater.locateView(self.templateId).then(function (element) {
    self.data("precompiled", null);
    var t = $(element).html();
    //system.log("got template: "+t );
    self.template(t);
    self.loaded = true;
  });
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top