我正在处理一个项目,该项目要求我从 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>");
});
}
});
};
您可以使用字符串操作。在下面的示例中,子字符串从指定的字符位置开始,一直到字符串的末尾(删除前 n 个字符:在给定的情况下 - "ID:"):
$(this).attr("attribute name").substring(3);