jqueryjqxgridjqwidget

jqxGrid enable & disable cells edit by dropdown


var rowEdit = function (row) {
    if (row == 0)
        return True;
}

I have jqxGrid with 6 Columns (Unique Number,Verified "Yes or No",Tracking Number,Serial Number,Condition,Remarks)

Verified "Yes or No" is a dropdownlist.

problem: base on column "Verified" i want to enable or disable the other fields. for example if "YES" enable for editing else if "NO" disable (no edits allowed)

please assist.


Solution

  • Using the cellbeginedit function in the columns property, you can define which column is editable or not.

    You have to define it on each column and inside the function, you check the value of the Verified column to determine if the column is editable (return true) or not (return false).

    The function takes 3 arguments

    1. The row index: which can be used to get all the row data (function getrowdata of the grid).
    2. The datafield: the one you've defined in the columns property.
    3. The column type.

    So, your rowEdit function should look like this:

    var rowEdit = function (rowindex, datafield, columntype) {
        if(datafield != "Verified"){
            var rowdata = $("#itemGrid").jqxGrid('getrowdata', rowindex);
            return rowdata.Verified == "YES";
        }
        return true;
    }
    

    I've used the value YES for the Verified column, because I ingore which is the correct value for this data.

    But, you can replace with the good one.