Author Topic: is it possible to make a particular cell not editable?  (Read 4838 times)

Leo F

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 21
    • View Profile
is it possible to make a particular cell not editable?
« on: February 10, 2014, 03:38:24 am »
Ok so this works for most cases, but I have a situation where in some rows some cells are editable, but not others. Screenshot attached(white cells are not editable, yellow and dark blue rows are not editable). There is no direct property of the ui object when the editable check is called that has the column index, but there is the ui.rowData["pq_cellselect"] which gets the dataIndx of the currently selected column. Unfortunately this property appears to only be available when a cell is clicked, if a user uses keyboard navigation this property is undefined. So as a workaround I am storing the last known selected column, but of course this only works if the user uses the up/down keys to navigate. Using tab, enter, or right key prevent this from working properly.

            obj.editable = function (ui) {
                var rowIndx = ui.rowIndx;
                var colIndx = getNameOfFirstObjectProperty(ui.rowData["pq_cellselect"]);
                if (!colIndx)
                    colIndx = grid.LastSelectedDataIndx;
                else
                    grid.LastSelectedDataIndx = colIndx;
               
                if (!$(this).pqGrid("hasClass", { rowIndx: rowIndx, dataIndx: colIndx, cls: 'gridCellDisabled' }) && $(this).pqGrid("hasClass", { rowIndx: rowIndx, cls: 'gridRowEditable' }))
                    return true;
                else
                    return false;
            };

How can I resolve this?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: is it possible to make a particular cell not editable?
« Reply #1 on: February 10, 2014, 12:02:06 pm »
The purpose of this callback is to check editable property for rows.

http://paramquery.com/pro/api#option-editable

To check it for cells use the column.editable callback

http://paramquery.com/pro/api#option-column-editable