mercredi 11 février 2015

checkbox remain checked on unchecking in client template of kendo grid

I have Kendo grid in which one column is checkbox. I am making the checkbox enable and disabled based on some conditions.When the checkbox is in enabled condition, on checking I am changing the value of next column.That is working fine but when I uncheck the checkbox for first time it remains check and value is changing and when I click it for second time it is becoming uncheck. Why checking behaviour is showing on double click and why not on single click.Can anyone please help me. Here is my kendo grid code:



columns.Bound(product => product.conversion_factor).Title(Resource.ConversionFactor);
columns.Bound(product => product.client_auto_reject).Hidden(true).Width(150);
columns.Bound(product => product.client_auto_reject).Title(Resource.AutoRejectHeader).ClientTemplate
("# if ((RoleName == 'bto_approvers') || (RoleName == 'bto_authorizer') || (RoleName == 'bto_readonly')) " +
"{# <input type='checkbox' #= client_auto_reject ? checked='checked': '' # class='CheckId' disabled='disabled' /> #} " +
"else {#<input type='checkbox' #= client_auto_reject ? checked='checked': '' # onclick='updateAmount(this, \"#= product_id#\")' />#}#");
columns.Bound(product => product.auto_reject_after_string).Title(Resource.AutoRejectAfter).Hidden(true).Width(150).Format("{0:MM/dd/yyyy}");
columns.Bound(product => product.auto_reject_after).Title(Resource.AutoRejectAfter).Width(150).Format("{0:MM/dd/yyyy}");
columns.Bound(product => product.product_name).Title(Resource.ProductName).Width(250);
columns.Bound(product => product.manufacturer_sku).Title(Resource.ManufacturerSKU).Width(170);


And here is the code I am writing for function updateAmount



function updateAmount(cb, ourID) {
debugger;
var checked = $(cb).is(':checked');
var grid = $('#grdclientProducts').data("kendoGrid");
var dataItem = grid.dataSource.get(ourID);
dataItem.set("client_auto_reject", checked);
if (checked) {
dataItem.set("client_auto_reject", 1);
}
else
{
dataItem.set("client_auto_reject", 0);
dataItem.set("auto_reject_after_string", "00/00/0000");
dataItem.set("auto_reject_after","00/00/0000");
}
}




Aucun commentaire:

Enregistrer un commentaire