Author Topic: Checkbox column radio option  (Read 2072 times)

joaosales

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 20
    • View Profile
Checkbox column radio option
« 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!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Checkbox column radio option
« Reply #1 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;
}
}
},