This is a migrated thread and some comments may be shown as answers.

Data-Template and Source binding with useWithBlock

4 Answers 235 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Roland
Top achievements
Rank 1
Roland asked on 16 Jul 2012, 11:07 AM
How can i define a data-template with a source binding using the useWithBlock:false

I have something like the following
<ul data-template="itemtemplate" data-bind="source: Data">

and my template
<script id="itemtemplate" type="text/x-kendo-template">
  <li>
    <div>
      <label data-bind="text: Description">
      </label>
    </div>
  </li>
</script>

but I want that my template will be rendered with the useWithBlock property set to false

4 Answers, 1 is accepted

Sort by
0
jstott
Top achievements
Rank 1
answered on 26 Jul 2012, 02:25 AM
Stumped on this one as well?
0
Atanas Korchev
Telerik team
answered on 26 Jul 2012, 06:04 AM
Hi,

 Currently Kendo MVVM initializes the templates with default configuration. This means that useWithBlock is always set to true. There is no way to override this unless the source code is modified.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jonathan M
Top achievements
Rank 1
answered on 11 Dec 2012, 11:48 PM

I know this is an older thread, but I had the same question come up today and thought I'd share my solution.

I just put this in a script block that runs before my template is initialized:

kendo.Template.useWithBlock = false;

Hope this helps someone.

Jonathan

0
Dani
Top achievements
Rank 2
answered on 25 May 2016, 09:43 PM

I took the modified source code route to solve my problem.  Performance in IE11 (still used by many on our corporate network) was abysmal, ranging from 60-90 seconds to load a very data-heavy page.  By turning off the useWithBlock on the biggest ListView on the page, it now loads in a more "acceptable" 15 seconds.  Using the 2016.1.412 release of kendo.mobile.js, I modified the parseOptions method at line 2200 as follows:

function parseOptions(element, options) {
    var result = {}, option, value;
    for (option in options) {
        value = parseOption(element, option);
        if (value !== undefined) {
            if (templateRegExp.test(option)) {
                var useWithBlock = !(element.getAttribute('data-use-with-block') === 'false');
                value = kendo.template($('#' + value).html(), { useWithBlock: useWithBlock });
            }
            result[option] = value;
        }
    }
    return result;
}

By adding the data-use-with-block="false" attribute to my mobile ListView widget, I can now specify the behavior on a per-control basis. Hope that helps!

Tags
MVVM
Asked by
Roland
Top achievements
Rank 1
Answers by
jstott
Top achievements
Rank 1
Atanas Korchev
Telerik team
Jonathan M
Top achievements
Rank 1
Dani
Top achievements
Rank 2
Share this question
or