Hi,
I thought my scenario was pretty simple, and should be fairly easy to achieve, but it's turning out to be a bit more complex :(
I have a list of invoices in a grid. Invoices have a capital amount and a fee amount.
The user can select if the client wants to settle(pay) the capital amount, the fee amount, or both.
When the user checks the capital and/or fee amount the settlement amount field is populated accordingly. All information required is in the underlying model data row.
I figured I'd just add some booleans to my model, create some check box columns bound to the booleans, and create some javascript events on change or on click to just set the payment amount based on what was clicked.
However, after much searching on this forum, it seems that I have to use client templates for the checkbox columns. Then when I tried that, I see they're all checked by default, the 'check binding' doesn't appear to work, and not sure exactly what events are fired and when. I can check the checkboxes before I enable inline editing, and when i do enable inline editing, the check box ticking doesn't fire any row changed events but if I click on the open space next to it, the field goes into edit mode then only.
It just feels messy.
I've searched the forums and it seems that there is no clean way to do this: https://www.telerik.com/forums/how-to-have-more-than-one-checkbox-column
I think with another few hours of messing around I can probably get this to work. But my question is:
What is the RECOMMENDED way to get this done?
I need additional checkbox columns. I need an event fired on changed or checked to update another field in the same row.
I will handle posting to the server later on via a button as i need to capture payment dates and references and stuff.
This is how far i got right now, checkboxes are ticked by default even though the model says false for those checkbox fields and the event is not firing at the right time, only at read which is wrong:
@(
Html.Kendo().Grid<
emscredit.Models.Invoice
>()
.Name("active-invoices-" + batch.batch.Id)
.Columns(columns =>
{
columns.Select().Title("Select All").Width(35);
columns.Bound(c => c.InvoiceNo);
columns.Bound(c => c.InvoiceAmount);
columns.Bound(c => c.SettleCapitalAmount).ClientTemplate("<
input
type
=
'checkbox'
\\#= SettleCapitalAmount ?
checked
=
'checked'
:'' \\# />");
columns.Bound(c => c.SettleFeeAmount).ClientTemplate("<
input
type
=
'checkbox'
\\#= SettleFeeAmount ?
checked
=
'checked'
:'' \\# />");
columns.Bound(c => c.TotalSettlement);
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(i => i.Id);
model.Field(c => c.InvoiceNo).Editable(false);
model.Field(c => c.InvoiceAmount).Editable(false);
})
.Read(read => read.Action("ReadActiveInvoices", "InvoiceGrid", new { batchId = batch.batch.Id }))
.PageSize(20)
.Events(events => events.Change("processReceiptsRowChanged()"))
)
)
Thanks,
Bruce