How can I get data of this selected item by clicking on ShortLink
which is at left side of Automate button in list view command bar at the top of the list?
1 Answer
You can get the data of selected list item on button click using onExecute()
method in SPFx List view command set.
For example:
@override
public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
//Get selected list item(s)
let selectedListItems = event.selectedRows;
}
If you want the first/single item selected, you can use:
@override
public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
//Get first selected list item
let selectedListItem = event.selectedRows[0];
}
Check this SPFx sample for detailed code and more information: JustALinkCommandSet.ts
-
hey how can i call the anormal js function in listview command extensions @ganeshSanap– KajalApr 27 at 10:21
-
Use SPComponentLoader for loading the files. Also, it is better to use Typescript code instead of JavaScript code in SPFx. check this if it helps: learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/… Apr 27 at 10:38