我处理的项目要求我从SharePoint 2013列表中提取数据并将该数据显示到html表中。正在查询和显示所有数据,但是两个查阅列显示“ID;#”。如何从值的前面删除它,只显示值?
function get() {
var method = "GetListItems";
var webURL = $().SPServices.SPGetCurrentSite();
var list = "QA_DailyStatus";
var fieldsToRead = "<ViewFields>" + "<FieldRef Name='ProjectRelease' />" + "<FieldRef Name='StastusDate' />" + "<FieldRef Name='ProductionReleaseDate' />" + "<FieldRef Name='Overall_QA_Status' />" + "<FieldRef Name='Overall_QA_Percent_Complete' />" + "</ViewFields>";
var query = "<Query><Where><Eq><FieldRef Name='Active_DSR' /><Value Type=\"bit\">1</Value></Eq></Where></Query>";
$().SPServices
({
operation: method,
async: false,
webURL: webURL,
listName: list,
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: query,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var Release = $(this).attr("ows_ProjectRelease");
var StatusDate = $(this).attr("ows_StastusDate");
var ProductionDate = $(this).attr("ows_ProductionReleaseDate");
var OverallStatus = $(this).attr("ows_Overall_QA_Status");
var PercentComplete = $(this).attr("ows_Overall_QA_Percent_Complete");
$("#myDataTable").append("<tr align='middle'>" +
"<td align='left'>" + Release + "</td>" +
"<td align='left'>" + StatusDate + "</td>" +
"<td align='left'>" + ProductionDate + "</td>" +
"<td align='left'>" + OverallStatus + "</td>" +
"<td align='left'>" + PercentComplete + "</td>" + "</tr>");
});
}
});
};
答案 0 :(得分:0)
您可以使用字符串操作。在下面的示例中,子字符串从指定的字符位置开始并继续到字符串的末尾(删除前n个字符:在给定的情况下 - “ID:”):
$(this).attr("attribute name").substring(3);