Conditional Form Editing

CloudTables incorporates many of the DataTables extensions, such as Buttons and Select, and you can use the APIs for these extensions within your code.

In this example, we're preventing any record with 'London' as the office from being edited or deleted. We do that by using one of Select's events to dtermine which row is selected, and to disable the button accordingly.

This example was achieved by adding the following code into the document:

document.addEventListener('ct-ready', function(e) {
  var table = e.table;

  // Only allow single row selection
  table.select.style('single');

  table
    .on('select', function(e, dt, type, index) {
      var office = JSON.parse(table.row(index).data()['dp-54'])[0].text

      if (office === 'London') {
        table.buttons([1,2]).disable();
      }
    })
    .on('deselect', function() {
      table.buttons([1,2]).disable();
    });
});

Other examples