admin管理员组

文章数量:1279008

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.

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.

Share Improve this question asked Jul 15, 2011 at 16:32 YellowcakeYellowcake 1163 silver badges9 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 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);
            }
        });

I was able to do this, but my solution was to ment 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 mented 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./1085623

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

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?

本文标签: javascriptHide checkbox only from header row of a slickgridStack Overflow