I created a new MVC project in visual Studio 2012, using the telerik KendoUI for MVC Web Application template (after installing the 2013.1.319 release) I then set up some grids and sparkline charts.
These have worked, but when I set up an editable grid, I've encountered issues
These have worked, but when I set up an editable grid, I've encountered issues
- The buttons for edit / update / cancel have the text underlined, like hyperlinks - which hasn't happened in other kendo projects I've created.
- Clicking the update button, the controller saves the change, but the web page doesn't close the edit, (both using inline and the pop-up editors).
- If I make the primary key field read-only, the value is not posted back to the controller, even though it's specified as the ModelID.
I have put the page and controller code in an older project (v2012.2.913) and the first two issues disappear.
The grid definition is:-
<
div
style
=
"font-size:small;width:700px; margin-bottom:15px;"
>
@(Html.Kendo().Grid<
PMS2Monitor.Models.SystemSetting
>()
.Name("settingsGrid")
.Columns(columns=>
{columns.Bound(p=>p.SettingCode);
columns.Bound(p => p.SettingDescription).Title("Description");
columns.Bound(p => p.SettingValue).Title("Value");
columns.Command(command => { command.Edit(); });
})
.Editable(editable=>editable
.Mode(GridEditMode.InLine))
.Pageable()
.Filterable()
.DataSource(dataSource=>dataSource
.Ajax()
.Model(m=>m.Id(p=>p.SettingCode))
.PageSize(8)
.Events(events => events.Error("error"))
.Read(read=>read.Action("InterfaceSettings","Home"))
.Update(update=>update.Action("UpdateSetting","Home"))
)
) </
div
>
The object meta data is defined as:-
[MetadataType(
typeof
(SystemSettingMD))]
public
partial
class
SystemSetting
{
public
class
SystemSettingMD
{
[ReadOnly(
true
)]
public
object
SettingCode {
get
;
set
; }
[ReadOnly(
true
), StringLength(50)]
public
object
SettingDescription {
get
;
set
; }
[StringLength(500), Required]
public
object
SettingValue {
get
;
set
; }
}
}
The controller is:-
public
ActionResult InterfaceSettings([DataSourceRequest] DataSourceRequest request)
{
var query = _repository.GetSettings();
query = query.OrderByDescending(c => c.SettingCode);
return
Json(query.ToDataSourceResult(request));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult UpdateSetting([DataSourceRequest] DataSourceRequest request, Models.SystemSetting setting)
{
try
{
_repository.updateSetting(setting);
return
Json(ModelState.ToDataSourceResult());
}
catch
(Exception ex)
{
ModelState.AddModelError(
"ERR1"
, ex.Message);
return
Json(ModelState.ToDataSourceResult());
}
}
I've attached a screenshot of the grid buttons.
Thanks