The requested page is not available for the requested platform. You are viewing the content for Default platform.
cut

RichEditCommands.createField Property

Gets a command to add a field at the current position in a document.

Declaration

readonly createField: CreateFieldCommand

Property Value

Type Description
CreateFieldCommand

A CreateFieldCommand object that provides methods for executing the command and checking its state.

Remarks

You can invoke this command by calling the execute method.

The execute method checks the command state (obtained using the getState method) before executing, and decides whether the action can be performed. The execute and getState methods are members of the CreateFieldCommand class.

You can execute the command without parameters or with an optional code parameter depending on your requirements:

  • The command without parameters creates an empty field and populates it with characters in the selected range if there are any;
  • The command with the code parameter creates and updates a field containing text received from the parameter.

Usage examples:


//example 1
richEdit.commands.createField.execute();

//example 2
richEdit.commands.createField.execute("TOC \\h \\c \"Figure\"");

//example 3
richEdit.commands.createField.execute();
richEdit.commands.insertText.execute("Date");
richEdit.commands.updateField.execute();

//example 4
var fieldCode = "Date";
richEdit.commands.insertText.execute(fieldCode);
richEdit.selection.intervals = [new ASPx.Interval(rich.selection.intervals[0].start - fieldCode.length, fieldCode.length)];
richEdit.commands.createField.execute();
richEdit.commands.updateField.execute();
See Also