Line 87: @*@Html.DropDownList("MjestoID", null, htmlAttributes: new { @class = "form-control" })*@ Line 88: Line 89: @Html.EJ().AutocompleteFor(m => m.MjestoID).Datasource((IEnumerable<Mjesto>)ViewBag.Mjesto).AutocompleteFields(df => df.Text("Naziv").Key("MjestoID")).Value(Model.Mjesto.Naziv) Line 90: @*@Html.EJ().AutocompleteFor(m => m.MjestoID, (Syncfusion.JavaScript.Models.AutocompleteProperties)ViewData["mjesto"])*@ Line 91:
Line 87: @*@Html.DropDownList("MjestoID", null, htmlAttributes: new { @class = "form-control" })*@ Line 88: Line 89: @Html.EJ().AutocompleteFor(m => m.MjestoID).Datasource((IEnumerable<Mjesto>)ViewBag.Mjesto).AutocompleteFields(df => df.Text("Naziv").Key("MjestoID")).Value(Model.Mjesto.Naziv) Line 90: @*@Html.EJ().AutocompleteFor(m => m.MjestoID, (Syncfusion.JavaScript.Models.AutocompleteProperties)ViewData["mjesto"])*@ Line 91:
[CSHTML]
<div class="form-group">
@Html.LabelFor(model => model.Naziv, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="hidden" id="Naziv_hidden" name="Naziv" />
@Html.EJ().AutocompleteFor(model => model.Naziv).Datasource((IEnumerable<DPForModel126.Models.Mjesto>)ViewBag.data).AutocompleteFields(df => df.Text("Naziv").Key("MjestoID")).PopupHeight("200px").PopupWidth("200px").ShowRoundedCorner(true).Value(Model.Naziv).ClientSideEvents(c => c.Select("onSelect"))
@Html.ValidationMessageFor(model => model.Naziv)
</div>
</div>
[Script]
function onSelect(args) {
$("#Naziv_hidden").val(args.key);
}
[Controller]
[HttpPost]
public ActionResult Edit(string Naziv)
{
int Id = Int32.Parse(Naziv);
var std = List.Where(s => s.MjestoID == Id).FirstOrDefault();
ViewBag.data = List;
return View(std);
} |