我的ASP.NET MVC项目中有一个Kendo UI AJAX网格,我想计算总检查列数。我有5个星期一到星期五(AM)列,5个星期一到星期五(PM)列,以及两个总列TotalAM和TotalPM。当用户单击复选框时,我需要计算TotalAM和TotalPM。
例如,如果选中星期一上午和星期二上午,则TotalAM应为2.同样,如果未选中PM列,则TotalPM应为0.
你能告诉我如何实现这个吗?
<%: Html.Kendo().Grid<SSTS.Models.ServiceUseViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(student => student.StudentNumber).Width(150);
columns.Bound(student => student.GivenName).Width(150);
columns.Bound(student => student.FirstDateOfTravel).Width(150);
columns.Bound(student => student.MondayAM).Width(150);
columns.Bound(student => student.MondayPM).Width(150);
columns.Bound(student => student.TuesdayAM).Width(150);
columns.Bound(student => student.TuesdayPM).Width(150);
columns.Bound(student => student.WednesdayAM).Width(150);
columns.Bound(student => student.WednesdayPm).Width(150);
columns.Bound(student => student.ThursdayAM).Width(150);
columns.Bound(student => student.ThursdayPM).Width(150);
columns.Bound(student => student.FridayAM).Width(150);
columns.Bound(student => student.FridayPM).Width(150);
columns.Bound(student => student.TotalDaysAM).Width(150);
columns.Bound(student => student.TotalDaysPM)
.Width(150).ClientTemplate("#=calculateField(data)#");
columns.Bound(student => student.IsMoreThanOnceService).Width(150);
columns.Command(commands =>
{
commands.Edit(); // The "edit" command will edit and update data items
commands.Destroy(); // The "destroy" command removes data items
}).Title("Commands").Width(150);
})
.ToolBar(toolbar => toolbar.Create()) // The "create" command adds new data items
.Editable(editable => editable.Mode(GridEditMode.InLine)) // Use inline editing mode
.DataSource(dataSource =>
dataSource.Ajax()
.Model(model =>
{
model.Id(student => student.StudentNumber); // Specify the property which is the unique identifier of the model
})
.Create(create => create.Action("serviceUse_Create", "ServiceUse")) // Action invoked when the user saves a new data item
.Read(read => read.Action("serviceUse_Read", "ServiceUse")) // Action invoked when the grid needs data
.Update(update => update.Action("serviceUse_Update", "ServiceUse")) // Action invoked when the user saves an updated data item
.Destroy(destroy => destroy.Action("serviceUse_Destroy", "ServiceUse")) // Action invoked when the user removes a data item
)
.Pageable().Scrollable()
%>