or
Grid in inline edit mode.
@(Html.Kendo().Grid<Security.UserViewModel>()
.Name(
"Users"
)
.Columns(columns =>
{
columns.Bound(c => c.UserId).Hidden();
columns.Bound(c => c.UserName).Title(
"Логин"
);
columns.Bound(c => c.FirstName).Title(
"Имя"
);
columns.Bound(c => c.LastName).Title(
"Фамилия"
);
columns.Bound(c => c.Email).Title(
"E-mail"
);
columns.ForeignKey(c => c.FirstRoleId, (System.Collections.IEnumerable)ViewData[
"roles"
],
"RoleID"
,
"RoleName"
).Title(
"Роль"
);
columns.Command(command =>
{
command.Edit();
command.Destroy();
});
})
.ToolBar(toolBar => toolBar.Create())
.Editable(editing => editing.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error(
"error"
))
.Model(model => {
model.Id(u => u.UserId);
})
.Create(update => update.Action(
"Create"
,
"Users"
))
.Read(read => read.Action(
"Read"
,
"Users"
))
.Update(update => update.Action(
"Update"
,
"Users"
))
.Destroy(delete => delete.Action(
"Delete"
,
"Users"
))
)
)
When I add new row grid sends to the server blank "FirstRoleName" instead of "FirstRoleId". When I update the row all works fine.
Made temporary workaround:
$(
function
() {
var
grid = $(
"#Users"
).data(
"kendoGrid"
);
// bind to the save event
grid.bind(
"save"
,
function
(e) {
if
(e.model.isNew()) {
e.model.FirstRoleId = $(
"input#FirstRoleId"
).val();
}
});
});
I think it is a bug.
<div class=
"DCF"
>
@using (Html.BeginForm(
"Search"
,
"Search"
, FormMethod.Post,
new
{ enctype =
"multipart/form-data"
}))
{
<span>DCF DB</span>
@(Html.Kendo().AutoComplete()
.Name(
"dcfSearchBox"
)
//
.DataTextField(
"results"
) //commented as the list of strings do not need a dataTextField defined to display
.Filter(
"contains"
)
.MinLength(3)
.HtmlAttributes(
new
{ style =
"width:250px"
})
.DataSource(source =>
{
source.Read(read =>
{
read.Action(
"SuggestionSearch"
,
"Search"
).Data(
"onAdditionalData"
);
})
.ServerFiltering(
true
);
})
.Template(
"#:results.Replace(dcfSearchBox.val(),\"<span style='font-weight: bold;'>#:dcfSearchBox.val()</span>\")#"
)
)
<br />
@(Html.Kendo().Button()
.Name(
"btnSubmit"
)
.HtmlAttributes(
new
{ type =
"submit"
})
.Content(
"Search"
)
)
}
</div>
<script>
function
onAdditionalData() {
return
{
text: $(
"#dcfSearchBox"
).val()
//,
//checkFilter: $("#dcfCheckFilter").is(':checked'),
//filterText: $("#dcfFilterText").val()
};
}
</script>
.Columns(columns =>
{
columns.Template(e => { }).ClientTemplate(" ").Title("Store Name");
columns.Bound(c => c.Value).Format("R {0:n2}");
columns.Bound(c => c.Quantity).Format("{0:n0}");
columns.Bound(c => c.ASP).Format("R {0:n2}");
})
.HtmlAttributes(new { style = "height: 900px;" })
.Events(ev => ev.DataBound("onDataBound"))
.ClientRowTemplate(
"<
tr
data-uid
=
'#: uid #'
>" +
"<
td
><
a
href
=
'/Dashboard/Store/#= StoreId #'
>" +
"#: Element #" +
"</
a
></
td
>" +
"<
td
class
=
'text-right'
>R " +
"#: Value #" +
"</
td
>" +
"<
td
class
=
'text-right'
>" +
"#: Quantity #" +
"</
td
>" +
"<
td
class
=
'text-right'
>R " +
"#: ASP #" +
"</
td
>"+
"</
tr
>"
)