0

I am working with jQuery plugin DataTables and its Editable plugin. I can set columns to be read-only via the parameter aoColumns:

 "aoColumns": 
               [
                    null,   
                    {}, 
                    {
                        indicator: 'Saving...',
                        type: 'select',
                        submit: 'Update',
                        loadURL: 'Home/Test',
                    }
                ]

I can also set each individual cell to read-only by adding read_only class:

<td class="read_only">...</td>

The above works fine as long as I do not specify aoColumns (i.e., all cells are editable by default). Is it possible to make certain cells read-only within an editable column? Notice the reasons I use aoColumns are to use the dropdown box and loadurl.

Sam
  • 7,252
  • 16
  • 46
  • 65
Alex
  • 331
  • 2
  • 9
  • Do you mean you want to set all cells in a column to read_only? – Barbara Laird Aug 08 '13 at 20:55
  • No, only certain cells in a column. For example, you have a Status column. The status can be Submitted, Approved, In Progress, and Completed. I want the cell to be read-only if the status is Completed; for other statuses, users can change to applicable statuses. – Alex Aug 08 '13 at 21:18

1 Answers1

1

I use the row callback for a similar problem. Something like this:

 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
            /* Append the read_only class to Completed rows */
            if ( aData["status"] == "Completed" )
            {
                nRow.className = "read_only";
            }
        },

http://datatables.net/usage/callbacks

Barbara Laird
  • 12,599
  • 2
  • 44
  • 57