Reactjs 使用spfx的Sharepoint列表中的项目计数
我需要Sharepoint列表中的“状态计数”列。我在spfx中使用了React作为模式Reactjs 使用spfx的Sharepoint列表中的项目计数,reactjs,sharepoint,spfx,Reactjs,Sharepoint,Spfx,我需要Sharepoint列表中的“状态计数”列。我在spfx中使用了React作为模式 @autobind private async _loadAsyncData(): Promise<Chart.ChartData> { const items: any[] = await sp.web.lists.getByTitle("Sales").items.select("Title", "Salesamt",
@autobind
private async _loadAsyncData(): Promise<Chart.ChartData> {
const items: any[] = await sp.web.lists.getByTitle("Sales").items.select("Title", "Salesamt", "Status").get();
let lblarr: string[] = [];
let dataarr: number[] = [];
items.forEach(element => {
lblarr.push(element.Title);
dataarr.push(element.Salesamt);
});
let chartdata: Chart.ChartData = {
labels: lblarr,
datasets: [{
label: 'My data',
data: dataarr
}]
};
return chartdata;
}
@autobind
私有异步\u loadAsyncData():承诺{
const items:any[]=wait sp.web.lists.getByTitle(“Sales”).items.select(“Title”、“Salesamt”、“Status”).get();
设lblarr:string[]=[];
让dataarr:number[]=[];
items.forEach(元素=>{
lblarr.push(元素名称);
数据传送推送(element.Salesamt);
});
让chartdata:Chart.chartdata={
标签:lblarr,
数据集:[{
标签:“我的数据”,
数据:dataarr
}]
};
返回图表数据;
}
有人能帮我得到上面代码中状态栏中的物品数量吗
如果你的列表不是很大,你可以考虑列举整个列表。 另一种方法是使用
RenderListData()
+CAML/Aggregations
const caml:ICamlQuery={
ViewXml:``
};
const r=await sp.web.list.getByTitle('mm').renderListData(caml.ViewXml);
控制台日志(r)代码>欢迎使用堆栈溢出!请(你得到一个徽章!)通读一下,尤其是你在这里的最佳选择是做你的研究,为相关的主题,所以,给它一个尝试。如果你在做了更多的研究后陷入困境,无法摆脱困境,请发布一份你的尝试,并明确指出你陷入困境的地方。人们会乐于帮助的。当列表中的项目超过5000项时,此操作将失败。如何获得“大”列表的实际项目数?问候莱夫