Author Topic: Checkbox Selection with Auto Save problem  (Read 4677 times)

Digital Logix

  • Newbie
  • *
  • Posts: 12
    • View Profile
Checkbox Selection with Auto Save problem
« on: February 19, 2016, 05:25:50 am »
I am using paramquery grid with asp.net web service as datasource. I have implemented auto save feature from demo:

http://paramquery.com/pro/demos/editing_instant

and also added a checkbox selection column to get ids of selected rows to implement custom features. I have used the following demo:

http://paramquery.com/pro/demos/checkbox_id

The auto save feature is working fine but on check/uncheck of checkbox for row selection it marks the row as dirty and posts the data to server. I have tried by setting editable to false on checkbox column but the selection did not work.

How can I make the grid to avoid auto save on row selection using checkbox?

Here is definition of checkbox selection column:

var colM = [{ dataIndx: 'state1', maxWidth: 30, minWidth: 30, align: 'center', resizable: false, type: 'checkBoxSelection', cls: 'ui-state-default', sortable: false, editor: false, dataType: 'bool', cb: { all: false, header: true, select: true }},
---
];

and here is the toolbar definition:

                    toolbar: {
                        items: [
                            { type: '<strong>' + title + '</strong>' },
                            {
                                type: 'button',
                                label: 'Get Row ID of selected rows',
                                listeners: [{ 'click': function () {
                                    var $grid = $(this).closest('.pq-grid'),
                                        data = $grid.pqGrid('option', 'dataModel.data'),
                                        checked = [];
                                    for (var i = 0, len = data.length; i < len; i++) {
                                        var rowData = data;
                                        if (rowData.state1) {
                                            checked.push(rowData.StudentsID);
                                        }
                                    }
                                    //sort the ids.
                                    checked = checked.sort(function (a, b) { return (a - b); })
                                    alert(checked);
                                }
                                }]
                            },
                            ---
                        ]
                    }


Please check my grid implementation using the following link:

http://digitallogix.net/pqtest/

Thank you

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: Checkbox Selection with Auto Save problem
« Reply #1 on: February 19, 2016, 12:17:35 pm »
beforeValidate event can be used to prevent tracking of certain fields.

Code: [Select]
beforeValidate: function(evt, ui){
if(ui.source == 'checkbox' ){
ui.track = false;
ui.history = false;
}
},

Digital Logix

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Checkbox Selection with Auto Save problem
« Reply #2 on: February 19, 2016, 07:10:36 pm »
Thanks for your suggestion, I have used it and it is not posting data to server now on row selection using checkbox.

I am facing another issue now. I have another checkbox column bound to database field and it is not working with auto save now. The column model is:

{"title":"Status","width":100,"dataIndx":"Status","dataType":"bool","type":"checkbox","hidden":false,"render": function (ui) { var a = 1; } ,"filter":{"type":"checkbox","subtype":"triple","condition":"equal","init": function (ui) { var a = 1; } ,"listeners":[{ 'click': function (evt, ui) { onfilter('Status', $(this), ui.value); } }],"prepend":{}},"editor":{"type":"textbox","init":{}},"editModel":{}}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: Checkbox Selection with Auto Save problem
« Reply #3 on: February 20, 2016, 04:35:36 pm »
Previous code stops tracking for all checkbox columns.

If there are multiple checkbox columns, please use this:

Code: [Select]
beforeValidate: function(evt, ui){
if(ui.source == 'checkbox' ){
ui.track = ui.history; //ui.history is false for checkbox selection columns.
}
},
« Last Edit: February 20, 2016, 04:42:17 pm by paramquery »

Digital Logix

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Checkbox Selection with Auto Save problem
« Reply #4 on: February 20, 2016, 06:35:21 pm »
Thanks it works.