Define the Item template for MVVM

6 posts, 1 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 06 Feb 2014 Link to this post

    This is what I'm trying...

    <select data-value-field="Id" multiple="multiple" data-placeholder="Select Category..." data-text-field="Title" data-item-template="#: data.FullPath #" data-role="multiselect" data-type="HierarchicalTaxa" >

    However its throwing an error
    Error: Syntax error, unrecognized expression: ##: data.FullPath #

    ??
  2. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 07 Feb 2014 Link to this post

    Hello Steve,

    Specifying a template as a data attribute is not supported. You will need to set a template ID instead of defining the inline template directly. Check this jsBin demo for more information.

    Regards,
    Georgi Krustev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 07 Feb 2014 in reply to Georgi Krustev Link to this post

    Ahhh, okay

    Hey can I ask another quick one along the same line?

    This is how I'm forming the <select> in the backend.  The problem is I need all of the properties in this query to be available in the template...is it doable at all with this method?

    categoriesDropDown.DataSource = transformedCategories.OrderBy(x => x.FullPath);
                                categoriesDropDown.ID = this.PropertyName;
                                categoriesDropDown.DataTextField = "Title";
                                categoriesDropDown.DataValueField = "Id";
                                categoriesDropDown.Attributes.Add("multiple", "multiple");
                                categoriesDropDown.Attributes.Add("data-type", "HierarchicalTaxa");
                                categoriesDropDown.Attributes.Add("data-role", "multiselect");
                                categoriesDropDown.Attributes.Add("data-text-field", "Title");
                                categoriesDropDown.Attributes.Add("data-value-field", "Id");
                                categoriesDropDown.Attributes.Add("data-item-template", "category-item-template");
                                categoriesDropDown.Attributes.Add("data-placeholder", "Select {0}...".Arrange(this.PropertyName));
                                categoriesDropDown.DataBind();
  5. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 07 Feb 2014 Link to this post

    nm, got it :D

    categoriesDropDown.Attributes.Add("data-source", ServiceStack.Text.JsonSerializer.SerializeToString(transformedCategories.OrderBy(x => x.FullPath)));
  6. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 07 Feb 2014 Link to this post

    Crap...hey Georgi, the problem with this method for me is on postback the previous selection is wiped out

    ...any suggestions?

    When it was bound with the DS the viewstate restored the selection
  7. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 10 Feb 2014 Link to this post

    Hello Steve,

    I am not exactly sure where could be the problem. It will be very helpful if you can send us a simple test project, which replicates the issue. Thus I will be able to review the current implementation and advice you further.

    Regards,
    Georgi Krustev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready