Reputation: 87
I want to get the values of the checkboxes if true then i need to add the calculated values in the Total column my code is
<%: Html.Kendo().Grid<SSTS.Models.ServiceUsedViewModel>()
.Name("grid")
.Columns(columns =>
{
// columns.Bound(student => student.CustomerName);
// columns.Bound(student => student.StudentNumber).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
// columns.Bound(student => student.GivenName).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.ForeignKey(p => p.StudentNumber, (System.Collections.IEnumerable)ViewData["students"], "StudentNumber", "StudentNumber")
.Title("StudentNumber").Width(150);
columns.Bound(student => student.FirstDateOfTravel).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.MondayAM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.MondayPM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.TuesdayAM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.TuesdayPM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.WednesdayAM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.WednesdayPM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.ThursdayAM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.ThursdayPM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.FridayAM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.FridayPM).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.TotalNumberOfDaysAM).Width(150).ClientTemplate("#= calculate() #"); ; ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.TotalNumberOfDaysPM).Width(150);//.ClientTemplate("#=MondaydPM#"); ; ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
columns.Bound(student => student.IsMoreThanOneService).Width(150); ;//.ClientTemplate("#=CustomerNames.CustomerName#").Width(160);
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.ServiceUseID); // Specify the property which is the unique identifier of the model
model.Field(p => p.StudentNumber).DefaultValue("");
})
.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()
%>
I have MondayAM/PM-FridayAm/PM checkboxes and there is TotalNumberofDaysAM/PM and i need to check how many AM/PM are checked and then add them to the totalnumber column anyone knows how to do it using jquery or javascript
Upvotes: 0
Views: 3560
Reputation: 40887
You might try using jQuery :checked
selector:
// Get reference to Grid
var grid = $("#grid").data("kendoGrid");
// Get the list of `input` that are checked
var clicked = $(":checked", grid.element);
// Display the length of the array that contains the inputs that are checked
console.log("clicked", clicked);
Example here : http://jsfiddle.net/OnaBai/JB2TD/
Upvotes: 1