Author Topic: Set property true/false on checkbox click and not cellClick  (Read 2857 times)

dev-ncw

  • Newbie
  • *
  • Posts: 6
    • View Profile
Set property true/false on checkbox click and not cellClick
« on: August 30, 2016, 11:05:56 am »
Hello,

My grid has 7 columns; Monday thru Sunday. These are all checkbox columns that allow user to select one or more columns. I've implemented these checkboxes using render call back function and cellClick event as follows:

Code: [Select]
{
                title: "Mon", dataIndx: "exceptionMon", width: 30, dataType: "boolean", align: "center", type: "checkbox", editable: false,
                render: function (ui) {
                   

                    return "<input type='checkbox' " + (ui.cellData ? "checked='checked'" : "") + "/>";

                }               
                , hidden: false
            }

Code: [Select]
$("#grid_array").pqGrid({
        cellClick: function (evt, ui) {
           
            if (exceptionDays.indexOf(ui.dataIndx) > -1) {
                var exceptionVal = ui.rowData[ui.dataIndx];
               
                if (exceptionVal == undefined || exceptionVal == false) {
                   
                    ui.rowData[ui.dataIndx] = true;

                } else {
                   
                    ui.rowData[ui.dataIndx] = false;
                }
            }

        }
    });

This works fine with only one problem. Because I've used cellClick event, the properties are set to True/False even if the cell is clicked and not the checkbox. Is there a way to set properties to true or false only when the checkbox is clicked?

Please let me know if you need additional information.

Thanks in advance.


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Set property true/false on checkbox click and not cellClick
« Reply #1 on: August 30, 2016, 02:58:51 pm »
evt.originalEvent.target can be checked to find out the origin of click.

dev-ncw

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Set property true/false on checkbox click and not cellClick
« Reply #2 on: August 30, 2016, 08:48:03 pm »
Perfect! Just what I needed! Thanks!