Author Topic: How can we add single selectable checkbox in a grid in Pivot mode?  (Read 3008 times)

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Our requirement is to add an checkbox in front of last child of group tree as shown in image2 below.

Checkbox should be single selectable at time and on checked its cell background-color should get change in any other color.

Please give some example of it.

Problem url:

https://stackblitz.com/edit/js-y31u1u?file=index.html
« Last Edit: June 05, 2020, 04:37:44 pm by EPM Solutions »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: How can we add single selectable checkbox in a grid in Pivot mode?
« Reply #1 on: June 05, 2020, 08:25:04 pm »
1. Do you need checkbox in front of each child node as highlighted in yellow in your image.

2. By single selectable, do you mean that when a checkbox is checked, other checkboxes should be unchecked and their background reset to default.

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Re: How can we add single selectable checkbox in a grid in Pivot mode?
« Reply #2 on: June 06, 2020, 11:32:12 am »
Hello Team,

Thanks for quick reply,

Yes I need the same. But when we checked a node, sets background-color to light red or purple of Company Name(chhild node). Checking another row causes previous row to be set unchecked(set default background).

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: How can we add single selectable checkbox in a grid in Pivot mode?
« Reply #3 on: June 08, 2020, 11:15:06 am »
1. Add these to groupModel

Code: [Select]
checkbox: true, cascade: false, useLabel: true

2. Implement the beforeCheck and check events to limit checkbox to single check and change cell style.

Code: [Select]
      beforeCheck: function(evt, ui){
        var G = this.Group();
        G.getCheckedNodes().forEach(function(node){
          node.pq_group_cb = false;
          node.pq_cellstyle[ui.dataIndx] = {};
        })
      },
      check: function(evt, ui){       
        var style = ui.rows[0].rowData.pq_cellstyle = {}; 
        style[ui.dataIndx] = {
          "background-color": (ui.check? "#aaffff": "")
        }
      },


https://stackblitz.com/edit/js-7wbsny?file=index.html
« Last Edit: June 08, 2020, 12:16:02 pm by paramvir »

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Re: How can we add single selectable checkbox in a grid in Pivot mode?
« Reply #4 on: June 08, 2020, 12:58:57 pm »
Hello Team,

Thanks,

I have one problem, I applied the your suggested css code in a grid with bootstrap theme in below URL.

It is not working. Can you please check it?

Problem URL:
https://stackblitz.com/edit/js-9vbyfq?file=index.js
« Last Edit: June 08, 2020, 01:11:47 pm by EPM Solutions »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: How can we add single selectable checkbox in a grid in Pivot mode?
« Reply #5 on: June 08, 2020, 02:47:30 pm »
It's not the bootstrap theme, but you are using an old 5.4 version of pqgrid in which this solution doesn't work.

Please upgrade the version.

https://stackblitz.com/edit/js-nzgynq?file=index.html

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Re: How can we add single selectable checkbox in a grid in Pivot mode?
« Reply #6 on: June 08, 2020, 03:54:34 pm »
Hello Team.

Thanks a lot. :)