0

我从事的项目需要我从 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>");

            });

        }

    });

};

4

1 回答 1

0

您可以使用字符串操作。在下面的示例中,子字符串从指定的字符位置开始并继续到字符串的末尾(删除前 n 个字符:在给定的情况下 - “ID:”):

$(this).attr("attribute name").substring(3);
于 2014-01-14T18:42:40.347 回答