List Item version history into data table

https://company.sharepoint.com/sites/sitename/_api/lists/getbytitle(‘List Name’)/Items(itemId)/Versions
Using above or sp.web.lists.getByTitle(“List Name”).items… how can i get version history information in datatable?

Dear @coresoul,

Could you please clarify what version history you want to retrieve? The screenshot will be very helpful.

This is a workaround to retrieve the item’s version history and store it in the datatable:

  1. You can retrieve the item’s version history by this code: https://github.com/SharePoint/PnP-JS-Core/issues/622

pnp.sp.web.getList(’/sites/site/lists/list’)
.items.getById(2)
.select(‘Versions’)
.expand(‘Versions’)
.get().then(console.log)

  1. You can populate the data table by this code: fd.control("DataTable0").widget.setOptions({dataSource:[{Column0: "Jane"},{Column0:"Ed"}]}) : https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/datasource

Notice that you should replace “DataTable0” with the internal name of your data table and “Column0” with the internal name of your column.

  1. You can form a data array from the Lookup data and pass it to the data source of the data table as shown above.

To have access to “fd” in the browser console, add this code in the JavaScript Editor: window.fd = fd; .

If you have any question about implementation - feel free to ask!

1 Like