Hi,
how do I send the current multiselect values to an asp.net mvc 4 action, as a IEnumerable<int>?
I have:
And I want to send the selected id's to an action which updates a model bound treeview:
This is my action to create the new model for the treeview:
So I need to do the following things:
1. Get the MultiSelect currently selected id's data passed to the server as an IEnumerable<int> into the index action with ajax request
2. Replace the content within the tree div with the new loaded treeview (if ajaxrequest, the action returns a partial view).
I am having trouble with number 1. Please give me some advice on how to solve this.
Thanks!
Best regards,
Marcus
how do I send the current multiselect values to an asp.net mvc 4 action, as a IEnumerable<int>?
I have:
@(Html.Kendo().MultiSelect()
.Name(
"Fields"
)
.DataTextField(
"Name"
)
.DataValueField(
"Id"
)
.Value(ViewData[
"tagslist"
]
as
IEnumerable<
int
>)
.Filter(FilterType.Contains)
.Placeholder(
"..."
)
.Events(e =>
{
e.Change(
"change_field"
);
})
.DataSource(source => {
source.Read(read =>
{
read.Action(
"ShowFields"
,
"Folders"
);
});
})
<div id=
"tree"
>
@(
Html.Kendo().TreeView()
.Name(
"treeview"
)
.ExpandAll(
true
)
.TemplateId(
"treeview-template"
)
.DragAndDrop(
true
)
.BindTo(Model)
.Events(events => events
.DragEnd(
"onDragEnd"
)
)
)
</div>
public
ActionResult Index(IEnumerable<
int
> fieldTags,
int
id = 1 )
{
IEnumerable<TreeViewItemModel> kendoModel =
new
List<TreeViewItemModel>();
SopFolder kendoStartFolder = db.SopFolders.Where(r => r.Id == id).Take(1).Select(r => r).ToList()[0];
kendoModel = CreateKendoTree(kendoStartFolder, fieldTags);
var SopFields =
db.SopFields
.Select(r =>
new
{
Value = r.Id,
Text = r.Name
});
List<
int
> tagslist =
new
List<
int
>();
foreach
(var tag
in
SopFields)
{
tagslist.Add(tag.Value);
}
ViewData[
"tagslist"
] = tagslist;
if
(Request.IsAjaxRequest())
{
return
PartialView(
"_Tree"
, kendoModel);
}
return
View(kendoModel);
}
So I need to do the following things:
1. Get the MultiSelect currently selected id's data passed to the server as an IEnumerable<int> into the index action with ajax request
2. Replace the content within the tree div with the new loaded treeview (if ajaxrequest, the action returns a partial view).
I am having trouble with number 1. Please give me some advice on how to solve this.
Thanks!
Best regards,
Marcus