Kendo 网格内联编辑 kendo 时间选择器未更改值
Kendo Grid Inline edit kendo timepicker not changing value
您好,当我想单击单元格进行更新时,我有带内联编辑的网格,我可以看到我的时间选择器,我可以看到 select 值,但是当我传递下一个单元格时,值正在消失而不是 select或改变任何东西
我该如何解决?
@( Html.Kendo().Grid<MockUpForeNet.Controllers.CardDetailController.Days>()
.Name("timegrid")
.DataSource(d => d.Ajax().Read("TimeGridBinding", "CardDetail", new { rule = rule }).Update("UpdateTime","CardDetail").Model(keys =>
{
keys.Id(k => k.DayId);
keys.Field(c => c.DayName).Editable(false);
keys.Field(c => c.DayId).Editable(false);
keys.Field("TimeStart", typeof(string)).Editable(true);
keys.Field("TimeEnd", typeof(string)).Editable(true);
}).PageSize(7))
.Columns(c =>
{
c.Bound(p => p.DayId).Width(100).Title(" ").ClientTemplate("#= chk2(data) #").Sortable(false);
c.Bound(e => e.DayName).Width(200).Title("Day");
c.Bound(e => e.TimeStart).Width(200).Title("Start Time").EditorTemplateName("StartTimeEditor");
c.Bound(e => e.TimeEnd).Width(200).Title("End Time").EditorTemplateName("EndTimeEditor");
})
.ToolBar(commands =>
{
commands.Save().SaveText(" ").CancelText(" ");
})
.Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InCell))
.Sortable()
.ColumnMenu()
)
这是我的示例编辑器
@(Html.Kendo().TimePicker().Name("txtend").Format("HH:mm").Value("23:59").Interval(30))
这是我的模型
public class Days
{
public int DayId { get; set; }
public string DayName { get; set; }
[DataType(DataType.Time)]
public DateTime TimeStart { get; set; }
public DateTime TimeEnd { get; set; }
}
这里是如何绑定数据的例子
Days d = new Days();
d.DayId = 1;
d.DayName = "Monday";
d.TimeStart = Convert.ToDateTime("00:00");
d.TimeEnd = Convert.ToDateTime("23:59");
添加带有编辑器模板的列作为
columns.Bound(c => c.TimeStart).Title("Trainer").EditorTemplateName("StartTimeEditor").Width(250);
您可以按如下方式更改编辑器模板
@using System.Collections
@(Html.Kendo().DateTimePicker()
.Name("TimeStart")
.TimeFormat("hh:mm")
.HtmlAttributes(new { style = "width:100%",data_format = "hh:mm" })
.Events(e =>
{
e.Change("DtChange");
})
)
使用选定的行 ID
编写如下更改函数 Dtchange()
function Dtchange() {
var dataSource = $("#Grid").data("kendoGrid").dataSource;
var data = dataSource.data();
$.each(data, function (index, rowItem) {
var date = data[index].TimeStart;
var newdate = moment(date).format('hh:mm');
if (newdate != 'Invalid date') {
data[index].set('TimeStart', newdate );
}
else {
data[index].set('TimeStart', "");
}
})
}
您好,当我想单击单元格进行更新时,我有带内联编辑的网格,我可以看到我的时间选择器,我可以看到 select 值,但是当我传递下一个单元格时,值正在消失而不是 select或改变任何东西
我该如何解决?
@( Html.Kendo().Grid<MockUpForeNet.Controllers.CardDetailController.Days>()
.Name("timegrid")
.DataSource(d => d.Ajax().Read("TimeGridBinding", "CardDetail", new { rule = rule }).Update("UpdateTime","CardDetail").Model(keys =>
{
keys.Id(k => k.DayId);
keys.Field(c => c.DayName).Editable(false);
keys.Field(c => c.DayId).Editable(false);
keys.Field("TimeStart", typeof(string)).Editable(true);
keys.Field("TimeEnd", typeof(string)).Editable(true);
}).PageSize(7))
.Columns(c =>
{
c.Bound(p => p.DayId).Width(100).Title(" ").ClientTemplate("#= chk2(data) #").Sortable(false);
c.Bound(e => e.DayName).Width(200).Title("Day");
c.Bound(e => e.TimeStart).Width(200).Title("Start Time").EditorTemplateName("StartTimeEditor");
c.Bound(e => e.TimeEnd).Width(200).Title("End Time").EditorTemplateName("EndTimeEditor");
})
.ToolBar(commands =>
{
commands.Save().SaveText(" ").CancelText(" ");
})
.Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InCell))
.Sortable()
.ColumnMenu()
)
这是我的示例编辑器
@(Html.Kendo().TimePicker().Name("txtend").Format("HH:mm").Value("23:59").Interval(30))
这是我的模型
public class Days
{
public int DayId { get; set; }
public string DayName { get; set; }
[DataType(DataType.Time)]
public DateTime TimeStart { get; set; }
public DateTime TimeEnd { get; set; }
}
这里是如何绑定数据的例子
Days d = new Days();
d.DayId = 1;
d.DayName = "Monday";
d.TimeStart = Convert.ToDateTime("00:00");
d.TimeEnd = Convert.ToDateTime("23:59");
添加带有编辑器模板的列作为
columns.Bound(c => c.TimeStart).Title("Trainer").EditorTemplateName("StartTimeEditor").Width(250);
您可以按如下方式更改编辑器模板
@using System.Collections
@(Html.Kendo().DateTimePicker()
.Name("TimeStart")
.TimeFormat("hh:mm")
.HtmlAttributes(new { style = "width:100%",data_format = "hh:mm" })
.Events(e =>
{
e.Change("DtChange");
})
)
使用选定的行 ID
编写如下更改函数Dtchange()
function Dtchange() {
var dataSource = $("#Grid").data("kendoGrid").dataSource;
var data = dataSource.data();
$.each(data, function (index, rowItem) {
var date = data[index].TimeStart;
var newdate = moment(date).format('hh:mm');
if (newdate != 'Invalid date') {
data[index].set('TimeStart', newdate );
}
else {
data[index].set('TimeStart', "");
}
})
}