Options
All
  • Public
  • Public/Protected
  • All
Menu

Options related to Editing in Adaptable.

Allows you to provide Adaptable with Server Validation that works in conjunction with Client (aka Cell) Validation

EditOptions Example

In this example we run Server Editing.

For the Amount column the (slightly contrived) logic is that any edit > 100 will return 100, any edit < 20 will return 20 and if edit is 50 its rejected.

Any edits that dont break those rules - or which are not for the 'amount' column - we ignore (so they will be processed normally)

adaptableOptions.editOptions = {
    validateOnServer: (dataChangedInfo: DataChangedInfo) => {
      return new Promise((resolve, reject) => {
        setTimeout(() => resolve(getServerEditResponse(dataChangedInfo)), 2000);
      });
    },
  };

--------------------

function getServerEditResponse(dataChangedInfo: DataChangedInfo): ValidationResult {
 if (dataChangedInfo.ColumnId == 'amount') {
   if (dataChangedInfo.NewValue == 50) {
    return {
      NewValue: dataChangedInfo.OldValue,
       ValidationMessage: 'Cannot set amount to 50',
     };
   } else if (dataChangedInfo.NewValue > 100) {
     return {
       NewValue: 100,
       ValidationMessage: 'Amount cannot be greater than 100',
     };
   } else if (dataChangedInfo.NewValue < 20) {
     return {
       NewValue: 20,
       ValidationMessage: 'Amount cannot  be less than  20',
     };
   }
 }
return {};
}

 --------------------

Hierarchy

  • EditOptions

Index

Properties

Optional displayServerValidationMessages

displayServerValidationMessages: boolean

Whether or not to display a message after Server Validation.

If set to true then an Info Message will appear with any ValidationMessage sent by ServerValidation; if there is no Validation Message then no popup is displayed.

Default Value: true

Optional validateOnServer

validateOnServer: (dataChangedInfo: DataChangedInfo) => Promise<ValidationResult>

Used when you want to check an Edit made in Adaptable on your Server

The argument provided is the DataChangedInfo object which provides the old and new values, the column, and also the node in which the cell lives.

The property returns a promise that includes a Validation Result

A ValidadtionResult has 2 properties: A new value to use instead of the proposed one from the edit and a message.

You can return an empty object if you are happy with the edit (and it will then go through as normal).

This function will only be called AFTER cell validation has successfully completed.

Default Value: null

Type declaration

Generated using TypeDoc