Created
January 23, 2021 09:48
-
-
Save anderseide/df405cb72441bb1461f45522f67886c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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