Hi,
Am using unboundcheckbox field in my webdatagrid. I need to disable the checkbox after 20 selections. How can i achieve it with using the row updating event.
Thanks,
vignesh
Hello Vignesh,
Thank you for posting in our forums!
If you are causing a postback each time a checkbox is selected, you could set a ColumnSetting so the column is set to ReadOnly. This forum thread shows a simple example
If you are not causing postbacks, you will need to handle this in javascript using the EditingCore's CellValueChanging event. In this event, you can create your logic to check if the user has made 20 selections and then call eventArgs.set_cancel(true) to prevent other checkboxes from being checked or unchecked. This forum thread provides an example of how you can handle the CellValueChanging event.
Please let me know if you need further assistance with this and I will be glad to help.
Here I have attached the javascript for getting the count of checkboxes I check. After 20 checkboxes I will display a confirm message box. If I try for “eventArgs.set_cancel(true);” am not able to get it. As it does not accept the “.set_cancel”. Please help me to disable after 20 records selection. Thanks in advance.
function webdatagrid1_Editing_CellValueChanged(sender, eventArgs)
{
var grid = $find("wdgMasterProject");
var columnKey = eventArgs.get_cell().get_column().get_key();
if (columnKey == "chkSelect") {
var rowsCount = grid.get_rows().get_length();
var number = document.getElementById("txtHidden").value;
for (var i = 0; i < rowsCount; i++) {
if (grid.get_rows().get_row(i).get_cellByColumnKey("chkSelect").get_value()) {
number = document.getElementById("txtHidden").value;
number++;
//alert(selRowsCount);
}
document.getElementById("txtHidden").value = number;
if (number > 20)
confirm("Please select only 20 values");