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

Error without data-role="listview" on MVVM and Templates

3 Answers 193 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 01 Jun 2012, 09:45 AM
Consider the code at: http://jsfiddle.net/vapKb/2/

It runs as is only because of the inclusion of data-role="listview" on the #folders div in the HTML. This has other meaning for kendo and k-widget class is added etc so, ideally, I'd like to be able to omit it?

If this attribute is removed, then an error is thrown:

Uncaught ReferenceError: Type is not defined 

Any thoughts?

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 05 Jun 2012, 06:57 AM
Hello Mark,

The dataSource is designed to work with widgets, not a simple templates. As a solution for your case, I recommend to bind the template to an array, thus way you should not receive the error.
var explorerModel = kendo.observable({
    expList: [
        {
            "UID": 26,
            "Title": "mdu test2",
            "Description": "wearing a big hat",
            "Type": "Folder"
        },
        {
            "UID": 27,
            "Title": "mdu test 3",
            "Description": "test large items",
            "Type": "Folder"
        }
    ],
    foo: "bar"
});

For convenience I modified your Fiddle, you can check the result here.
I hope this helps.

Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mark
Top achievements
Rank 1
answered on 06 Jun 2012, 07:34 AM
Hi Alexander,

Thanks for the reply. Unfortunately it doesn't really solve my problem since, for my actual solution, I'm using remote data hence using dataSources.

It is not clear, to me at least, that dataSources are only for use with widgets. There are some of your own web demos: http://demos.kendoui.com/web/datasource/remote-data.html where the dataSource is not used specifically for a widget.

I would imagine that I am not the only customer who has requirements where using your dataSource with arbitrary templates is useful. In would not be practical for you to have a widget for every possible scenario.

I realize that I could use the dataSource with remote data and then have code that populates an array tied to my templates however this diminishes the value in using the product. I would much prefer to be able to create applications that have a consistent approach to data, logic and presentation.

Given that the templates almost work as is (by setting data-role) would it not be possible to enhance the product to support templates & dataSources in the future?

Thanks,

Mark.


0
Accepted
Alexander Valchev
Telerik team
answered on 07 Jun 2012, 12:34 PM
Hi Mark,

Thank you for the feedback, I will forward it to the team for further discussions.
Regarding to the demo that you pointed, it does not assign a dataSource to the template, instead it renders the template using the dataSource view - an array of objects.
change: function() { // subscribe to the CHANGE event of the data source
    $("#tweets").html(kendo.render(template, this.view()));
}

If you wish you can use a similar workaround in your case, to illustrate the implementation I updated the previous example.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Mark
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or