sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

ListView CommandSet - onExecute parameters has wrong selectedRows (in a Doc Library)

Open jimmywim opened this issue 7 years ago • 11 comments

Within onExecute, and you inspect event.selectedRows.getValueByName("ID"), the first time you execute the command for a selected item this is correct, but if you highlight another row, and execute the command, the value returned by the getValueByName doesn't update.

If you change the row selection using the checkbox on the left column this gets the correct value.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

jimmywim avatar Oct 16 '19 14:10 jimmywim

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Oct 16 '19 14:10 msft-github-bot

Code being used (Adapted from scaffolded code from Yeoman generator for a ListView Extension):

  @override
  public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
    switch (event.itemId) {
      case 'COMMAND_1':
        Dialog.alert(`SELECTED ITEM: ${event.selectedRows[0].getValueByName("ID")}`); // This is the modified line from the scaffolded code
        break;
      case 'COMMAND_2':
        Dialog.alert(`${this.properties.sampleTextTwo}`);
        break;
      default:
        throw new Error('Unknown command');
    }
  }

jimmywim avatar Oct 16 '19 15:10 jimmywim

I seem to be having the same issue for list extension, the first item is fine but for the next item it receives the same rowid as the first. As soon as I right click on an item it remembers the selected id, if I then click out of the list and right click on another item, same thing happens. Been happening since yesterday.

zaiby avatar Oct 17 '19 08:10 zaiby

I seem to be having the same issue for list extension, the first item is fine but for the next item it receives the same rowid as the first. As soon as I right click on an item it remembers the selected id, if I then click out of the list and right click on another item, same thing happens. Been happening since yesterday.

Does the rowid come through correctly if you use the checkbox/selector in the first column on the view?

jimmywim avatar Oct 17 '19 08:10 jimmywim

:O yes it does.

zaiby avatar Oct 17 '19 08:10 zaiby

@zaiby That's the issue I'm seeing. The Row ID only updates correctly when selecting the row using the row selector. Do what any normal user does and just click somewhere else in the row to select it, and the rowid doesn't change.

jimmywim avatar Oct 17 '19 08:10 jimmywim

yes, same issue

zaiby avatar Oct 17 '19 08:10 zaiby

Thanks for submitting this, but as you said in the other issue submitted previously, this is identical to the #4769. As such, let's keep things consolidated...

andrewconnell avatar Oct 20 '19 10:10 andrewconnell

@andrewconnell Up to you which ticket to nix, mine has the docs metadata :)

jimmywim avatar Oct 20 '19 10:10 jimmywim

All that's used for is to keep the issue tied to the page where the comment was left. It doesn't impact the issue.

I know there is work being done on the list codebase around events... unclear exactly what's being done of if this is related so I have to research...

andrewconnell avatar Oct 20 '19 10:10 andrewconnell

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 23 '20 06:01 msft-github-bot