jQuery Grid
Set the disabled property of the jqxGrid.
Author: http://jqwidgets.com
HTML
<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="https://jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<div id="jqxgrid"></div>
JavaScript
//Choose the row indexes you wish to disable
var rowsToDisable = [0, 2, 3];
function disableCheckBoxes(rowsToDisable) {
let checkboxes = Array.from(document.querySelectorAll(".jqx-checkbox"));
checkboxes.shift();
checkboxes.forEach((checkbox) =>
checkbox.firstChild.classList.remove("disabled-checkbox")
);
checkboxes = checkboxes.filter((el) =>
el.parentNode.parentNode.children[1].firstChild.classList.contains(
"disable-checkbox"
)
);
checkboxes.forEach((checkbox) =>
checkbox.firstChild.classList.add("disabled-checkbox")
);
}
var cellsrenderer = function (row, column, value, defaultHtml) {
if (rowsToDisable.includes(row)) {
let parent = document.createElement("div");
parent.innerHTML = defaultHtml;
let element = parent.firstChild;
//Apply any style you wish on the cells
element.style.color = "#999";
element.classList.add("disable-checkbox");
return element.outerHTML;
}
return defaultHtml;
};
var data = generatedata(50);
var source = {
localdata: data,
datafields: [{
name: 'firstname',
type: 'string',
}, {
name: 'lastname',
type: 'string'
}, {
name: 'productname',
type: 'string'
}, {
name: 'date',
type: 'date'
}, {
name: 'quantity',
type: 'number'
}, {
name: 'price',
type: 'number'
}],
datatype: "array"
};
var adapter = new $.jqx.dataAdapter(source);
$("#jqxgrid").jqxGrid({
width: 500,
theme: 'energyblue',
disabled: false,
source: adapter,
sortable: true,
selectionMode: 'checkbox',
columns: [{
text: 'First Name',
datafield: 'firstname',
width: 90,
cellsrenderer,
}, {
text: 'Last Name',
datafield: 'lastname',
width: 90,
cellsrenderer,
}, {
text: 'Product',
datafield: 'productname',
width: 170,
...