I currently have the multiselect working the way I want it with one exception. Preloading previously selected items.
My view looks:
<div class="editor-field">
@Html.LabelFor(model => model.UntaggedPersons)
@Html.ListBoxFor(model => model.PeopleToTag,
new SelectList(Model.CommitteeMembers, "PersonId", "FullName"))
</div>
JS:
$("#PeopleToTag").kendoMultiSelect({ "dataTextField": "FullName", "dataValueField": "PersonId", "placeholder": "Tag or Untag Persons to Action Item", "value": "taggedPersons" });
PeopleToTag is an IEnumerable<int> that posts to the controller
CommitteeMembers consists of a persons First, Last, FullName, and PersonId
This works perfectly, I can manipulate who is tagged in post to the controller.
Now I want to add the functionality of preselecting those that are currently tagged.
How do I add a preselected Value? I have a model with: model.TaggedPersons consists of a persons First, Last, Fullname, PersonId. How do I wire up the javascript to display the model.TaggedPersons as the already selected value?
I don't mind using the MVC wrapper approach if it is easier.
I've tried something like:
<div class="editor-field">
@Html.LabelFor(model => model.TaggedPersons)
@(Html.Kendo().MultiSelect()
.Name("PeopleToTag")
.Placeholder("These people are Tagged")
.BindTo(new SelectList(Model.CommitteeMembers, "PersonId", "FullName"))
.Value(Model.TaggedPersons)
)
</div>
However this isn't even rendering a kendo multiselect for me at present. I perhaps have a reference issue to work out there. That's the general thought of how I want to approach it though.
Any help is much appreciated!
-Trevor
My view looks:
<div class="editor-field">
@Html.LabelFor(model => model.UntaggedPersons)
@Html.ListBoxFor(model => model.PeopleToTag,
new SelectList(Model.CommitteeMembers, "PersonId", "FullName"))
</div>
JS:
$("#PeopleToTag").kendoMultiSelect({ "dataTextField": "FullName", "dataValueField": "PersonId", "placeholder": "Tag or Untag Persons to Action Item", "value": "taggedPersons" });
PeopleToTag is an IEnumerable<int> that posts to the controller
CommitteeMembers consists of a persons First, Last, FullName, and PersonId
This works perfectly, I can manipulate who is tagged in post to the controller.
Now I want to add the functionality of preselecting those that are currently tagged.
How do I add a preselected Value? I have a model with: model.TaggedPersons consists of a persons First, Last, Fullname, PersonId. How do I wire up the javascript to display the model.TaggedPersons as the already selected value?
I don't mind using the MVC wrapper approach if it is easier.
I've tried something like:
<div class="editor-field">
@Html.LabelFor(model => model.TaggedPersons)
@(Html.Kendo().MultiSelect()
.Name("PeopleToTag")
.Placeholder("These people are Tagged")
.BindTo(new SelectList(Model.CommitteeMembers, "PersonId", "FullName"))
.Value(Model.TaggedPersons)
)
</div>
However this isn't even rendering a kendo multiselect for me at present. I perhaps have a reference issue to work out there. That's the general thought of how I want to approach it though.
Any help is much appreciated!
-Trevor