解决sharepoint数据过多超过域值问题以及分页筛选
解决sharepoint数据过多超过域值问题以及分页筛选
获取第一页
参数country为筛选条件
this.filterObj['Country'] = this.currentSelectCountry;
this.filterObj['Department'] = this.currentSelectDepartment;
this.filterObj['SortBy'] = this.currentSelectSort;
this.filterObj['SearchKey'] = this.searchKey;
public async getStaffs(country) {
let xmlStr = '';
let i = 0;
for (var key in country) {
if (country[key] != 'all') {
switch (key) {
case 'Country':
case 'Department': {
xmlStr += `<Eq><FieldRef Name='${key}'/><Value Type="Text">${country[key]}</Value></Eq>`;
break;
}
case 'SortBy': {
xmlStr += `<BeginsWith><FieldRef Name='LastName'/><Value Type="Text">${country[key]}</Value></BeginsWith>`;
break;
}
case 'SearchKey': {
xmlStr += `
<Or>
<Or>
<Or>
<Contains>
<FieldRef Name='FirstName'/>
<Value Type="Text">${country[key]}</Value>
</Contains>
<Contains>
<FieldRef Name='LastName'/>
<Value Type="Text">${country[key]}</Value>
</Contains>
</Or>
<Contains>
<FieldRef Name='JobTitle'/>
<Value Type="Text">${country[key]}</Value>
</Contains>
</Or>
<Contains>
<FieldRef Name='Email'/>
<Value Type="Text">${country[key]}</Value>
</Contains>
</Or>`;
break;
}
}
i++;
if (i >= 2) {
xmlStr = `<And>${xmlStr}</And>`
}
}
}
let camlQuery = `<View><Query><Where>${xmlStr}</Where></Query><RowLimit Paged='TRUE'>15</RowLimit></View>`;
this.camelQuery = camlQuery;
const renderListDataParams: IRenderListDataParameters = {
ViewXml: camlQuery,
};
let itemsResults = await (await sp.web.lists.getByTitle(this.listName).renderListDataAsStream(renderListDataParams)).Row;
const lastItem = itemsResults[itemsResults.length - 1];
let items: any = {};
items['results'] = itemsResults;
items['last'] = lastItem;
return items;
获取下一页
public async getNextStaffs(last) {
const renderListDataParams: IRenderListDataParameters = {
Paging: `Paged=TRUE&p_ID=${last.ID}&p_Title=${last.Title}`,
ViewXml: this.camelQuery,
};
let itemsResults = await (await sp.web.lists.getByTitle(this.listName).renderListDataAsStream(renderListDataParams)).Row;
const lastItem = itemsResults[itemsResults.length - 1];
let items: any = {};
items['results'] = itemsResults;
items['last'] = lastItem;
return items;
}

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)