Author Topic: Get id of selected checkboxes outside of the grid  (Read 351 times)

niketnaik

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Get id of selected checkboxes outside of the grid
« on: November 21, 2022, 10:56:49 am »
I want to access selected checkboxes from outside of the grid. Check the attachment. I tried using below code
 
 
Code: [Select]
var array = []
            var checkboxes = document.querySelectorAll('input[type=checkbox]:checked');
            for (var i = 0; i < checkboxes.length; i++) {
                array.push(checkboxes[i].value);
            }

But this code skips the values of checkboxes which are on next page or in the scroll down area. I want to access all the checkboxes.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Get id of selected checkboxes outside of the grid
« Reply #1 on: November 21, 2022, 11:12:16 am »
Please check this example: https://paramquery.com/pro/demos/checkbox_id

Code: [Select]
                        var checked = grid.Checkbox('state').getCheckedNodes().map(function(rd){
return rd.id
})
                        alert(checked);

where grid is js instance of grid.

If you don't have access to the js instance, then you can use jQuery selector to get to it,

Code: [Select]
var grid = $( selector of grid ).pqGrid( 'instance' );

More about grid variable here: https://paramquery.com/pro/tutorial#topic-special-vars
« Last Edit: November 21, 2022, 11:14:08 am by paramvir »

niketnaik

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Get id of selected checkboxes outside of the grid
« Reply #2 on: April 01, 2023, 11:50:10 am »
Worked
« Last Edit: April 01, 2023, 01:54:01 pm by niketnaik »