Author Topic: Setting all rows containing a checkbox column, checked  (Read 344 times)

pbassey

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 48
    • View Profile
Setting all rows containing a checkbox column, checked
« on: January 24, 2025, 09:58:29 pm »
Can you tell me how to set all rows that contain a checkbox column to checked?

I am using the following column where the "checked" attribute is set to true, but no rows are being checked:

        colModel = [
            {
                title: "FAS Activity", dataType: "string", dataIndx: "FASActivity", editable: false, align: "left", minWidth: '20%',
                render: function (ui) {
                    return "<a href='#' onClick=javascript:OpenTranWindow(" + "'" + ui.cellData + "'" + ");>" + ui.cellData + "</a>";
                }
            },
            { title: "Region", dataType: "String", dataIndx: "RegionDesc", editable: false, minWidth: '40%', },
            {
                title: "Include ?", dataIndx: "Activity", type: 'checkbox', editable: false,
                cbId: 'chk', hidden: false, checked: true, useLabel: false, minWidth: '20%'
            },
            {
                dataIndx: 'chk',
                dataType: 'bool',
                cb: { header: true },
                hidden: true,
                editable: function (ui) {
                    //to make checkboxes editable selectively.
                    return !(ui.rowData.Activity.length > 10);
                }
            }
        ];

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6352
    • View Profile
Re: Setting all rows containing a checkbox column, checked
« Reply #1 on: January 24, 2025, 11:27:29 pm »
there are 2 ways to initially check checkboxes in all rows:

1) Either set chk property of every row to true.

or

2) In complete event, call the checkbox API, grid.Checkbox('Activity').checkAll();

reference: https://paramquery.com/pro/api#method-Checkbox