问题描述
我正在使用kendo多列下拉列表,但似乎无法从DatValueField中获取值,我正在使用该值来获取所选人员的ID,以便将其存储在另一个表中。>
如果有人可以告诉我如何在bootstrap中复制同一内容,请执行telerik并不是我唯一的答案,而是避免使用tbh
<form asp-action="LinkToCase" method="post" asp-controller="MISObjects">
<div class="row">
<div class="col-md-12">
<div class="card card-success">
<div class="card-header" style="background-color:#1e3f5a;color:white">
<h3 class="card-title">Search and Tag</h3>
</div>
<div class="card-body">
<div class="col-md-12">
<div class="input-group">
<select id="searchOptions" name="searchOptions" style="background-color: #1e3f5a; color: white; width: 140px; height: 45px">
<option selected value="1">Poi</option>
<option selected value="1">Vessel</option>
</select>
@(Html.Kendo().multicolumnComboBox()
.Name("tagItem")
.DataTextField("name")
.DataValueField("SearchId")
.Filter("contains")
.FilterFields(new string[] { "name","ContactTitle","CompanyName","Country" })
.Columns(columns =>
{
columns.Add().Field("name").Title("Contact Name").Width("200px");
columns.Add().Field("dob").Title("Date Of Brith").Width("200px");
})
.FooterTemplate("Total #: instance.dataSource.total() # items found")
.HtmlAttributes(new { style = "width:80%;" })
.Height(400)
.DataSource(source => source
.Custom()
.Transport(transport => transport
.Read(read =>
{
read.Action("SearchQuery","MISObjects")
.Data("onAdditionalData");
}))
)
)
<button type="submit" class="btn-primary" value="Link To Case" style=" background-color:#1e3f5a;color:white">Link To Case</button>
</div>
</div>
</div>
</form>
[HttpPost]
public IActionResult LinkToCase(int SearchId,string updateInfo,int tagItem,string sesearchOptionsr,IFormCollection formItems) {
Int32.TryParse(TempData.Peek("CaseId").ToString(),out int resultCaseId);
var test = formItems;
POI newPoi = new POI();
newPoi = _context.Pois.SingleOrDefault(w => w.Id == SearchId);
newPoi.MISObjectId = resultCaseId;
_context.Pois.Add(newPoi);
_toast.AddSuccesstoastMessage(
$"You have linked {newPoi.FirstName} {newPoi.LastName} to case {resultCaseId:d8}");
return RedirectToAction("Edit",new { id = resultCaseId });
}
private IEnumerable<Searchviewmodel> GetSearchRecords() {
return _context.Pois.Where(w => w.isActive == true && w.isDeleted == false).Select(person =>
new Searchviewmodel {
SearchId = person.Id,Name = person.FirstName + " " + person.LastName,dob = person.dob
}).ToList();
}
但是即使当我检查SearchId时,即使我将其设置为int,它也还是空白的,因为我在路上时放了一张支持票,但看到它们是kendo标签,因此认为也可以在这里尝试
编辑2
您将在下面看到,在表单收集项中找不到该值。
解决方法
如果我正确地阅读了代码,对我来说,您想要的SearchId值应该已经在控制器方法的tagItem int参数中,因为这是表单中MultiColumnComboBox的名称。该MultiColumnComboBox绑定到一个具有SearchId作为值字段的列表,该列表是不同的,并且不会在提交时发回。