How to get all items in list view from SPFX ListView Command set onExecute()?
-
08-02-2021 - |
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');
}
}
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()
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange