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

Define the Item template for MVVM

5 Answers 135 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Veteran
sitefinitysteve asked on 06 Feb 2014, 09:11 PM
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 #

??

5 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 07 Feb 2014, 11:06 AM
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!
0
sitefinitysteve
Top achievements
Rank 2
Veteran
answered on 07 Feb 2014, 02:48 PM
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();
0
sitefinitysteve
Top achievements
Rank 2
Veteran
answered on 07 Feb 2014, 02:52 PM
nm, got it :D

categoriesDropDown.Attributes.Add("data-source", ServiceStack.Text.JsonSerializer.SerializeToString(transformedCategories.OrderBy(x => x.FullPath)));
0
sitefinitysteve
Top achievements
Rank 2
Veteran
answered on 07 Feb 2014, 04:09 PM
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
0
Georgi Krustev
Telerik team
answered on 10 Feb 2014, 04:28 PM
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!
Tags
MultiSelect
Asked by
sitefinitysteve
Top achievements
Rank 2
Veteran
Answers by
Georgi Krustev
Telerik team
sitefinitysteve
Top achievements
Rank 2
Veteran
Share this question
or