Author Topic: Check a checkbox only by click exactly on it  (Read 2539 times)

marco.fuhrmann

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 6
    • View Profile
Check a checkbox only by click exactly on it
« on: April 07, 2015, 06:21:40 pm »
Hello,

is it possible to make a checkbox "checked" only by clicking exactly on the checkbox?
Currently a checkbox is checked also when you click next to her.

I try to check out if the checkboxes (in column 2) are changed:
Code: [Select]
$('#evnTabelle').on('change', 'td:nth-child(2)', function (e) {
alert("change");
});
It worked, when i click exactly at a checkbox or the header-checkbox. But when i click next to a checkbox the checkbox is checked, but with "on change" i don`t get any event. I do not know how I can observe the entire column.

Thx,
Marco.
« Last Edit: April 07, 2015, 06:31:20 pm by marco.fuhrmann »

marco.fuhrmann

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Check a checkbox only by click exactly on it
« Reply #1 on: April 07, 2015, 07:01:49 pm »
I could solve it by using "pqgridcheck and pqgriduncheck at the same time.

Code: [Select]
$("#evnTabelle").on("pqgridcheck", function (event, ui) {
            var ergebnis = summePrivatverbindungen();
            document.getElementById("summe").innerHTML = ergebnis + " EUR";
});
$("#evnTabelle").on("pqgriduncheck", function (event, ui) {
            var ergebnis = summePrivatverbindungen();
            document.getElementById("summe").innerHTML = ergebnis + " EUR";
});

    function summePrivatverbindungen() {
            var $grid = $("#evnTabelle").closest('.pq-grid');
            data = $grid.pqGrid('option', 'dataModel.data');
            markierte = [];
            var summe = 0;
            var betragFloat = 0.00;
            for (var i = 0, len = data.length; i < len; i++) {
                var rowData = data[i];
                if (rowData.state) {
                    var ausgewaehlte = {};
                    var betrag = verguenstigungen(rowData.Art, rowData.EUR, "punkt");
                    betragFloat = parseFloat(betrag);
                    markierte.push(betrag);
                    }
            }
            var ausgabe = 0;
            for (var k = 0; k < markierte.length; k++) {
                ausgabe = ausgabe + parseFloat(markierte[k]);
            }
            var summe = ausgabe.toFixed(2);
            var summe = summe.replace(".", ",");
            return summe;
     }

Thx,
Marco

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Check a checkbox only by click exactly on it
« Reply #2 on: April 07, 2015, 09:48:47 pm »
you can observe the ui.source value in check and uncheck events.

if ( ui.source == 'header' ) //header checkbox is checked that implies whole column is affected.

http://paramquery.com/pro/api#event-check