Question

Is it possible to get all (not only selected) rows\items in ListView when ListView Command Set onExecute() method is called?

E.g.:

  @override
  public onExecute(event: IListViewCommandSetExecuteEventParameters): void {

    switch (event.itemId) {
      case 'COMMAND_1':
        let rows = this.context.listView.getAllRows() // <! something like that?
        break;
      case 'COMMAND_2':
        Dialog.alert('COMMAND Two');
        break;
      default:
        throw new Error('Unknown command');
    }
  }
Was it helpful?

Solution

Workaround:

Get list view id, then get items based on id.

case 'COMMAND_1':
        console.log(this.context.pageContext.legacyPageContext);
        var viewId=this.context.pageContext.legacyPageContext.viewId;
        Dialog.alert(viewId);
        break;

pnp.sp.web.lists.getByTitle("").views.getById()

How get sharepoint list items by view(s) in spfx?

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top