Author Topic: Enable row selection with checkbox Id selection  (Read 11728 times)

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Enable row selection with checkbox Id selection
« on: January 10, 2019, 08:12:45 am »
{
                 title: "Id",
                 width: 220,
                 dataIndx: "Id",
                 type: 'checkbox',
                 cbId: 'state',
                 useLabel: true
             },
              {
                  dataIndx: 'state',
                  dataType: 'bool',
                  cb: { header: true },
                  hidden: true,
                  editable: function (ui) {
                      //to make checkboxes editable selectively.
                      return true;
                  }
              },

checkbox column has disabled checkboxes. They are not getting enabled. Need help

The grid is readonly grid. I want to enable row selection and cell selection for copying so for row selection trying to implement checkbox column.

In version 3.4 row was selected when selected on number cell. It is not getting selected anymore. Can you support this functionality in grid V5.6
https://paramquery.com/pro/demos33/selection_cell

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #1 on: January 10, 2019, 12:54:16 pm »
   colModel:
            [
                { title: "ID", width: 100, dataType: "integer", dataIndx: "id", type:'checkbox', cbId: 'state', editable: false },
                //hidden column to store checkbox states.
                {
                    dataIndx: 'state',
                    cb: {header: true, select: true, all: true},
                    dataType: 'bool',
                    hidden: true
                },
                { title: "Company", width: 220, dataType: "string", dataIndx: "company", editable: false },
                { title: "Revenues ($ millions)", width: 180, dataType: "float", format: "#.00", dataIndx: "revenues", editable: false },
                { title: "Profits ($ millions)", width: 170, dataType: "float", format: "#.00", dataIndx: "profits", editable: false }
            ]

https://paramquery.com/pro/demos/selection_checkbox

I think there is a bug. For read only grid, row selection should enable copying rows or range of cells but it is not working.

when i removed editable: false from grid option and moved it to each column editable:false then row selection is working. Isn't it same thing as grid.editable = false.

I liked implementation in 3.4 of selecting the row when number cell was clicked. 
Now we have to add more code to add state column backend and front end  to get row selection working.  The hidden column of state is getting displayed in column selector. If it is hidden it should not show in column selector. how do i get rid of hidden column from column selector?



I would like to have support in latest version for 3.4 implementation of row selection, perhaps with some option please?


Also when whole row is selected using checkbox, it is not getting copied using ctrl C ?
« Last Edit: January 10, 2019, 01:14:11 pm by kshipra »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #2 on: January 10, 2019, 03:57:42 pm »
1. Column in which checkbox state is saved should be editable. All other columns can be either editable or uneditable. You may use columnTemplate to set editable: false on all other columns.

2. Please set selectionModel.row = true to select rows upon click on number cell.

https://paramquery.com/pro/api#option-selectionModel

3. When there are both row and cell selections, then cell selections are copied. If you need to copy row selections only, then disable the cell selections.

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #3 on: January 23, 2019, 03:52:10 am »
https://paramquery.com/pro/demos33/selection_cell

In this version by default cell and row selections are supported. My users need that ability to select cells or row by default.
This functionality is changed in upgraded version of 5.6.

Can you support this capability?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #4 on: January 23, 2019, 06:07:46 pm »
Both row and cell selections are supported in v5.6, they don't work in the same exact manner as in old versions and it won't be changed to match old versions.

If you are missing some functionality, please let know.

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #5 on: January 23, 2019, 10:34:38 pm »
 We have users that work heavily in excel and we are trying to give them same functionality on web. This is basic functionality of excel that should not have been broken in upgraded versions. You are breaking user base applications and not supporting us. I have to answer to my users as to why this functionality is not working anymore. I told them I am working with pqgrid team on this.
« Last Edit: January 23, 2019, 10:46:46 pm by kshipra »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #6 on: January 23, 2019, 11:29:55 pm »
I'm sorry can you please elaborate which basic functionality you found missing in v5.6?

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #7 on: January 23, 2019, 11:39:57 pm »
By default  simultaneous support of cell and row selections as in excel. An user should not be made to choose an option if he/she wants to have row selection or cell selection enabled.

It is working properly in this version of grid
https://paramquery.com/pro/demos33/selection_cell

Here user has to choose which selection he wants to have
https://paramquery.com/pro/demos52/selection_multiple

« Last Edit: January 23, 2019, 11:41:49 pm by kshipra »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #8 on: January 24, 2019, 03:06:57 pm »
Please try this code

Code: [Select]
            cellClick: function(evt, ui){
                //debugger;
                var len = this.getColModel().length;
                if( ui.$td.hasClass("pq-grid-number-cell") ){
                    this.Selection().replace({r1: ui.rowIndx, c1: 0, rc:1, cc:len, firstR:ui.rowIndx, firstC: len});
                    this.focus({rowIndxPage: ui.rowIndxPage, colIndx: 0})
                }
            }


PS: Please try to avoid multiple questions in a single topic if possible.
« Last Edit: January 24, 2019, 07:11:35 pm by paramquery »

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #9 on: January 24, 2019, 10:45:34 pm »
I tried the code provided. I found 2 issues with it:

1. It is not selecting multiple rows with shift and ctrl keys
2. I have functionality of copying data from selected rows.
$grid.pqGrid("SelectRow").getSelection()

This is not working. It is not returning any data.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #10 on: January 24, 2019, 11:30:59 pm »
1. I'm able to select multiple rows with shift but agree that Ctrl - shift doesn't work with this for selecting non-contiguous rows.

2. These are actually based on cell selections so Selection object has to be used for getting selections.

https://paramquery.com/pro/api52#method-Selection

Please let me know whether it works for you or need further assistance, if not then I'm afraid you have to use checkbox column for row selections and cell selections work as usual.

as in this example: https://paramquery.com/pro/demos52/selection_checkbox
« Last Edit: January 24, 2019, 11:34:40 pm by paramquery »

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #11 on: January 25, 2019, 01:02:20 am »
var sel = $grid.pqGrid("Selection");
var arr = sel.getSelection();

getSelection gives me whole big array with multiple rows data in it.
I need to have array for each selected row. I do not have fixed columns, they can choose columns so for me to figure out how many rows are selected is hard.

How can I find that out?

I feel this is kind of hack or quick fix.
Can you support this capability in upcoming releases of the grid ?  That would be really great if you can do that.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #12 on: January 25, 2019, 10:44:34 am »
sel.getSelection() returns all the selected cells.

Since you are interested in rows only and Selection inherits all methods of Range object, please use sel.addressLast() which provides r1 and r2 i.e, rowIndx of first selected row and rowIndx of last selected row.

https://paramquery.com/pro/api52#method-Range

Quote
Can you support this capability in upcoming releases of the grid ?  That would be really great if you can do that.

Sure, I would try to add that support back though it would be slight different because of difference in API.

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #13 on: January 25, 2019, 12:46:21 pm »
Thank you for your current help. Which release should I expect this support to be available?
Currently I have to  modify all of my screens to support these changes.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Enable row selection with checkbox Id selection
« Reply #14 on: January 28, 2019, 10:28:13 am »
ETA is March 2019.