DEV Community

Discussion on: SPFx 1.14 List View Command Set - UPDATE 31.03.2022

Collapse
 
ukurze profile image
UKurze

Try this:

public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters) : void {
this.Log('Start onListViewUpdated');

  var selectedRowCount: Number = event.selectedRows.length;

    // commands are enabled only if one item is selected
    var hasSingleSelection: boolean = selectedRowCount == 1;
    this._setCommandEnabled(hasSingleSelection);
Enter fullscreen mode Exit fullscreen mode

}

private _setCommandEnabled(commandId:string, enabled: boolean) : void {
this.Log(Start _setCommandEnabled commandId: ${commandId} enabled: ${enabled});
const command: Command = this.tryGetCommand(commandId);
if (command) {
command.disabled = !enabled;
}
}

Collapse
 
kkazala profile image
Kinga

Thank you @ukurze for weighing in :)

I see you are using deprecated onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters), whilst my goal is to make my code working with the new listViewStateChangedEvent.

The issue #7845 already has a fix and is being slowly rolled out. Still doesn't work in my tenant, but any day now, I think =)