Asp.net mvc 多选剑道UI ASP.NET MVC
如何在剑道网格ASP.NET MVC中按AddNewRubrica时将字段SearchSources添加为multiselect剑道ui 我的模型:Asp.net mvc 多选剑道UI ASP.NET MVC,asp.net-mvc,kendo-ui,multi-select,Asp.net Mvc,Kendo Ui,Multi Select,如何在剑道网格ASP.NET MVC中按AddNewRubrica时将字段SearchSources添加为multiselect剑道ui 我的模型: public class Rubrica { [ScaffoldColumn(false)] public int Id { get; set; } public string Title { get; set; } public string LookUps { get; set; } [Scaffol
public class Rubrica
{
[ScaffoldColumn(false)]
public int Id { get; set; }
public string Title { get; set; }
public string LookUps { get; set; }
[ScaffoldColumn(false)]
public DateTime CreateDateTime { get; set; }
[UIHint("SearchSourcesEditor")]
public IEnumerable<SearchSource> SearchSources { get; set; }
}
public class SearchSource
{
[ScaffoldColumn(false)]
public int Id { get; set; }
public string Url { get; set; }
public string Title { get; set; }
}
公共类Rubrica
{
[脚手架立柱(假)]
公共int Id{get;set;}
公共字符串标题{get;set;}
公共字符串查找{get;set;}
[脚手架立柱(假)]
公共日期时间CreateDateTime{get;set;}
[UIHint(“SearchSourcesEditor”)]
公共IEnumerable SearchSources{get;set;}
}
公共类搜索源
{
[脚手架立柱(假)]
公共int Id{get;set;}
公共字符串Url{get;set;}
公共字符串标题{get;set;}
}
SearchSourcesEditor.cshtml:
@using oko.Models
@using Kendo.Mvc.UI
@model IEnumerable<SearchSource>
@( Html.Kendo().MultiSelectFor(m => m)
.DataTextField("Url")
.DataValueField("Id")
.BindTo((IEnumerable<SearchSource>)ViewData["searchSources"]))
@使用oko.Models
@使用Kendo.Mvc.UI
@模型IEnumerable
@(Html.Kendo().MultiSelectFor(m=>m)
.DataTextField(“Url”)
.DataValueField(“Id”)
.BindTo((IEnumerable)ViewData[“searchSources”])
在mvc查看页面中:
<label for="required">show lable string value</label>
@(Html.Kendo().MultiSelect()
.Name("required")
.Placeholder("Select...")
.DataTextField("Text")
.DataValueField("Value")
.DataSource
(dataSource => dataSource
.Read(read => read.Url(Url.HttpRouteUrl("ActionApi", new { controller = "Home", action = "ReadMultiSelect" })))
)
)
在Mvc控制器中:
[UIHint("View Page Name")]
public string Column-field-name{ get; set; }
[HttpGet]
public IHttpActionResult ReadMultiSelect()
{
var model = Getvalues();
return Json(model);
}
[HttpGet]
public IHttpActionResult Getvalues()
{
// Object of your model
var result = new List<Your-Model-Name>();
// your logic here....
.......................................
// please note : always return in Json : if you dont do this you never get record in multiselect.
return Json(result);
}
[HttpGet]
公共IHttpActionResult ReadMultiSelect()
{
var model=Getvalues();
返回Json(模型);
}
[HttpGet]
公共IHttpActionResult Getvalues()
{
//模型的对象
var result=新列表();
//你的逻辑在这里。。。。
.......................................
//请注意:始终以Json返回:如果您不这样做,您永远不会在multiselect中获得记录。
返回Json(结果);
}
Баааааааааа,ааааааааа