Show CommandSet Button if more than 1 row is selected in SharePoint Online SPFx Yeoman generator 1.18.2

29 Views Asked by At

I have the following question: I'm currently working in SPFx with the yeoman generator 1.18.2. I want to use an CommandSet Extension.

I try to show a button if more than 1 row is selected. In an older SPFx Version I could write:

const compareTwoCommand: Command = this.tryGetCommand('COMMAND_2');
if(compareTwoCommand){
compareTwoCommand.visible = event.selectedRows.length > 1;
}

But now it has been changed and I can't use this lines of code any longer. I tried:

const compareTwoCommand: Command = this.tryGetCommand('COMMAND_2');
if (compareTwoCommand) {
  // This command should be hidden unless exactly one row is selected.
  compareTwoCommand.visible = this.context.listView.selectedRows?.length > 1;
}

What am I writing wrong? this.context.listView.selectedRows?.length is red underlined.

Best regards

0

There are 0 best solutions below