Author Topic: help for check box in the table  (Read 439 times)

ibizlink

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 8
    • View Profile
help for check box in the table
« on: June 08, 2022, 06:44:39 pm »
Hi

I have implemented check box in paramquery table as per below and it works well.

Code: [Select]
{
                    dataIndx: 'state',maxWidth: 30, minWidth: 30, align: "center", resizable: false, title: "",
                    menuIcon: false, sortable: false, editor: false, editable: true, menuInDisable: true,
                    type: 'checkbox', cls: 'ui-state-default',
                    dataType: 'bool',
                    cb: {
                        all: true, //checkbox selection in the header affect current page only.
                        header: true //show checkbox in header.
                    },
                    render: function (ui) {
                        if (ui.rowData.summaryRow) {
                            return "";
                        }
                        else
                        {
                            let column = this.getColumn({ dataIndx: 'state' }),
                                state = ui.rowData.state,
                                check = column.cb.check,
                                checked;
                           
                            if (state === check || ui.rowData.chkeod == 1)
                            {
                                checked = 'checked';
                            }
                            else
                            {
                                checked = '';
                            }

                            return {
                                text: "<label><input type='checkbox' " + checked + " /></label>"
                            }
                        }
                    }
                },

The issue is that it does not work with the below code as nothing come up with "rd".

Code: [Select]
Checkbox('state').getCheckedNodes().map(function (rd) {
                let obj = { id: rd.accountdetailid }
                result.push(obj);
            })


I have attached images that showing it actually selected but all check box on top has not checked as well.

Can you please adivse me how to bind actual check box from the begining?
(If I recheck it then looks like check box selected correctly)

Thanks,



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: help for check box in the table
« Reply #1 on: June 09, 2022, 02:17:19 pm »
Rather than manually generating the html of checkboxes, let the pqgrid API take care of it. It would also fix the issue faced by you.

Please follow this example: https://paramquery.com/pro/demos/checkbox
« Last Edit: June 09, 2022, 02:42:37 pm by paramvir »