Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anderseide/df405cb72441bb1461f45522f67886c8 to your computer and use it in GitHub Desktop.
Save anderseide/df405cb72441bb1461f45522f67886c8 to your computer and use it in GitHub Desktop.
@override
public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
const commandOne: Command = this.tryGetCommand('COMMAND_ONE');
const commandTwo: Command = this.tryGetCommand('COMMAND_TWO);
const commandThree: Command = this.tryGetCommand('COMMAND_THREE');
// Hide commands by default
commandOne.visible = false;
commandTwo.visible = false;
commandThree.visible = false;
// See https://{tenant}.sharepoint.com/sites/{siteName}/_api/web/lists(guid'{listId}')/Fields
// for list of fields that can be used for filtering
if (event.selectedRows.length === 1) {
const selectedRow = event.selectedRows[0];
// Command One should only be visible if ListField is empty
if (selectedRow.getValueByName("ListField") === "") {
commandOne.visible = true;
}
// Command Two and Command Three should visible if ListField have a value
if (selectedRow.getValueByName("ListField") !== "") {
commandTwo.visible = true;
commandThree.visible = true;
}
// Hide all commands if the item is a folder
if (selectedRow.getValueByName("ContentType") === "Folder") {
commandOne.visible = false;
commandTwo.visible = false;
commandThree.visible = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment