4

enter image description here

Code1:

var checkboxSelector = new Slick.CheckboxSelectColumn({
                                                          cssClass: "slick-cell-checkboxsel"

                                                      });

tempColumns.push(checkboxSelector.getColumnDefinition());

Code2:

    tempGrid.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow:false}));
tempGrid.registerPlugin(checkboxSelector);

I am using the above code to show the checkbox column.

How to hide checkbox only from header row of a slickgrid? (under red circle in the image)

Thanks.

Yellowcake
  • 116
  • 3
  • 9

3 Answers3

8
grid.onHeaderRowCellRendered.subscribe(function (e, args) {
            if (args.column.id === '_checkbox_selector') {
                // do something if you want
            } else {
                $(args.node).empty();
                $('<input type="text">')
                    .data('columnId', args.column.id)
                    .val(columnFilters[args.column.id])
                    .appendTo(args.node);
            }
        });
Ivo Nikolov
  • 81
  • 1
  • 1
3

I was able to do this, but my solution was to comment out a few lines in the slick.checkboxselectcolumn.js file. From what I can tell, handleSelectedRowsChanged() actually rewrites the contents of the checkbox cell header with a new <input> element on every change -- it doesn't just change the checked attribute. So I've commented out the lines in that function that make the swap, as well as a few others that add the checkbox at init and the event to (de)select all.

https://gist.github.com/1085623

There's probably a better way to approach this, but I needed to get something out the door ASAP.

bryanbuchs
  • 462
  • 2
  • 7
1

You can use jQuery to remove the checkbox.

$('.slick-header-columns input[type="checkbox"]').remove();

However, that checkbox on the header row allows you to do "Check All". Are you sure you want to remove it?

Craig M
  • 5,598
  • 4
  • 32
  • 43
  • Thanks for your reply but unfortunately your method is not safe, i.e. when you select last row's checkbox, the checkbox appears in the header. Can you suggest me how can I add a column of checkbox without using Slick.CheckboxSelectColumn? – Yellowcake Jul 15 '11 at 18:01
  • That would be rather complicated and could break other parts of the control. You might ask someone on their support forum. http://groups.google.com/group/slickgrid?pli=1 – Craig M Jul 15 '11 at 18:12