SetLock

function SetLock(sLockType: contentLocked | sdtContentLocked | sdtLocked = null): void

Description

Sets the lock to the current inline text content control: "contentLocked" - content cannot be edited. "sdtContentLocked" - content cannot be edited and the container cannot be deleted. "sdtLocked" - the container cannot be deleted.

Parameters

sLockTypecontentLocked | sdtContentLocked | sdtLockeddefault: null

The lock type applied to the inline text content control.

Returns

void

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oInlineLvlSdt = Api.CreateInlineLvlSdt();
oParagraph.AddInlineLvlSdt(oInlineLvlSdt);
var oRun = Api.CreateRun();
oRun.AddText("This is an inline text content control with the content lock set to it.");
oInlineLvlSdt.SetLock("sdtContentLocked");
oInlineLvlSdt.AddElement(oRun, 0);
var sLock = oInlineLvlSdt.GetLock();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Lock type: " + sLock);
oDocument.Push(oParagraph);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).