3

I have a grid with the plugin Slick.CheckboxSelectColumn.

Is it possible, without Jquery, to hide checkboxes in some rows? I guess it's possible using Formatter.

Here is the var with the slickgrid checkbox plugin:

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

Columns definition:

var columns = [
        { id: "Id", name: "Id", field: "Id", sortable: true, width: 40 },            
        { id: "Status", name: 'Status', field: "Status", sortable: true, width: 80 },
        checkboxSelector.getColumnDefinition()
     ];

Code to create grid and register plugins:

grid = new Slick.Grid("#grid", dataView, columns, options);
     grid.registerPlugin(new Slick.AutoTooltips({ enableForHeaderCells: true }));
     grid.registerPlugin(checkboxSelector)

SOLUTION

Use a custom plugin checkboxselectcolumn.js, create by @JamesSilberbauer

user959
  • 31
  • 1
  • 3

1 Answers1

5

You can do so using the formatter. Before adding the column definitions to the columns list, you need to alter the formatter. This is how:

var selectorColumnDef = checkboxSelecter.getColumnDefinition();
var currentFormatter = selectorColumnDef.formatter;
selectorColumnDef.formatter = function(row, cell, value, columnDef, dataContext) {
   if (showCheckBox) {
      return currentFormatter(row, cell, value, columnDef, dataContext);
   }
   return "";
};
var columns = [
        { id: "Id", name: "Id", field: "Id", sortable: true, width: 40 },            
        { id: "Status", name: 'Status', field: "Status", sortable: true, width: 80 },
        selectorColumnDef
     ];
Amir Geri
  • 399
  • 1
  • 8
  • A custom plugin [checkboxselectcolumn.js](https://gist.github.com/jcsjcs/10038299), create by @JamesSilberbauer. It´s perfect. Thanks for your attention. – user959 Apr 11 '14 at 14:40