igGrid only one non editable column
by georgianastasov
HTML
<script src="https://igniteui.com/js/modernizr.min.js"></script>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<script src="https://cdn-na.infragistics.com/igniteui/latest/js/infragistics.core.js"></script>
<script src="https://cdn-na.infragistics.com/igniteui/latest/js/infragistics.lob.js"></script>
<script src="https://igniteui.com/js-data/northwind"></script>
<link href="https://cdn-na.infragistics.com/igniteui/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet"></link>
<link href="https://cdn-na.infragistics.com/igniteui/latest/css/structure/infragistics.css" rel="stylesheet"></link>
<table id="grid"></table>
<br />
<textarea rows="4" cols="85" placeholder="Paste here.." style="font-size:1.2rem"></textarea>
JavaScript
$(function () {
//boolean variable
var ednterEditRow = false;
$("#grid").igGrid({
primaryKey: "EmployeeID",
width: '100%',
autoCommit: true,
columns: [
{ headerText: "Employee ID", key: "EmployeeID", dataType: "number", width: "15%" },
{ headerText: "First Name", key: "FirstName", dataType: "string", width: "25%" },
{ headerText: "Last Name", key: "LastName", dataType: "string", width: "25%"},
{ headerText: "Title", key: "Title", dataType: "string", width: "35%" }
],
autofitLastColumn: false,
autoGenerateColumns: false,
dataSource: northwind,
responseDataKey: "results",
//handle cellClick event
cellClick: function(evt, ui) {
//if the click is on FirstName cancel the edit
if (ui.colKey === "FirstName") {
ednterEditRow = false;
} else {
//else the click is on other columns enter edit
ednterEditRow = true;
}
},
features: [
{
name: "Updating",
enableAddRow: true,
editMode: "row",
enableDeleteRow: true,
columnSettings: [
{
//only when edit read only column
columnKey: "FirstName",
readOnly: false
}
],
//handle row edit starting event
editRowStarting: function(evt, ui){
//cancel the edit if ednterEditRow is false
if (!ednterEditRow) {
...