ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: joaosales on January 29, 2018, 07:25:00 pm

Title: Checkbox column radio option
Post by: joaosales on January 29, 2018, 07:25:00 pm
Hi,
I saw at a different topic someone asking about the  option to check only one box in a column and the answer was to use the radio:true option, but how do we build the column?
As a normal Checkbox type? I've done like this but i'm still able to check multiple rows

 
Code: [Select]
            {
                title: "Total",
                dataIndx: "sumRow",
                type: 'checkbox',
                cb: {
                    radio: true,
                    check: "YES", //check the checkbox when cell value is "YES".
                    uncheck: "NO" //uncheck when "NO".
                },
            }

Thanks!
Title: Re: Checkbox column radio option
Post by: paramvir on January 29, 2018, 11:05:40 pm
You may have read the post of pqSelect about radio: true option.

checkbox column in grid can be limited to one check only with help of beforeCheck event.

In this event, we check the count of checked and return false if it's already > 0.

Code: [Select]
beforeCheck: function(evt, ui){
if(ui.check){
if(this.option('dataModel.data').filter(function(rd){
return rd.Discontinued == 'YES'; //Discontinued is dataIndx of checkbox column with 'YES' / 'NO' values.
}).length){
return false;
}
}
},