1

我正在使用 SPServices - GetListItems ajax 从 SharePoint 2010 检索 Kendo Grid 的数据。然后我将标题绑定到 URL 模板。这可以正常工作(除了一个网格的链接会生成一个跨站点脚本错误,点击该项目。这很奇怪,因为页面和链接在同一个站点中)。

我更愿意链接到底层工作流实例,但在 GetListItems 返回的任何结果或底层 XML 数据(通过 Stramit Caml 查看器查看)中都找不到所需的唯一 ID。

这感觉笨重且硬编码,如果有人更改特定环境列表,则可能会中断。

在一个完美的世界中,我将能够从 ListItem 中检索整个链接,就像它在 SharePoint 中显示的那样,并在我的自定义页面中发出它。

有没有办法做到这一点?

编辑 我正在检索的列表项来自一个库,其中的列显示链接,这些链接将您带到项目的关联工作流。我想从我的网格中显示的项目直接链接到此工作流,就好像我正在查看 SharePoint 中的文档库本身一样。代码:

var carformData = [];
$(document).ready(function () {
    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "CAR Form",
        CAMLViewFields: "<ViewFields><FieldRef Name='WorkflowInstanceID' /><FieldRef Name='Title' /><FieldRef Name='Modified' /><FieldRef Name='CAR_x0020_ID' /><FieldRef Name='Phase1Fi' /><FieldRef Name='Phase2Ex' /><FieldRef Name='APPceo' /></ViewFields>",
        CAMLQuery: "<Query><Where><Eq><FieldRef Name='Author' /><Value Type='User'><UserID /></Value></Eq></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy></Query>",
        completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function () {
                carformData.push({
                    Title: $(this).attr("ows_Title"),
                    Modified: $(this).attr("ows_Modified"),
                    CARID: $(this).attr("ows_CAR_x0020_ID") != undefined ? $(this).attr("ows_CAR_x0020_ID") : "",
                    Phase1: $(this).attr("ows_Phase1Fi") != undefined ? workflowStatusCodes[$(this).attr("ows_Phase1Fi")] : "",
                    Phase2: $(this).attr("ows_Phase2Ex") != undefined ? workflowStatusCodes[$(this).attr("ows_Phase2Ex")] : "",
                    Phase3: $(this).attr("ows_APPceo")!= undefined ? workflowStatusCodes[$(this).attr("ows_APPceo")] : "",
                    WorkflowID: $(this).attr("ows_WorkflowInstanceID") //Note: This never has a value, even though these list items are associated with a Workflow, and display a link to them when viewing the Library
                });
            });
        }
    });
    $("#gridCar").kendoGrid({
        sortable: true,
        columns: [
            { field: "Title", title: "Name", template: "<a href='/CIS/CAR%20Form/${ Title }'>${ Title }</a>" },
            { field: "Modified", title: "Modified", format: "{0: MM/dd/yyyy}",  width: 80, headerAttributes: { style: "text-align: center" }, attributes: { style: "text-align: center" } },
            { field: "CARID", title: "CAR ID", width: 80, headerAttributes: { style: "text-align: center" }, attributes: { style: "text-align: center" } },
            { field: "Phase1", title: "Phase 1 - Finance & Accounting", width: 192 },
            { field: "Phase2", title: "Phase 2 - Executive Approval", width: 182 },
            { field: "Phase3", title: "Phase 3 - CEO Approval", width: 151 }
        ],
        dataSource: {
            data: carformData,
            schema: {
                model: {
                    fields: {
                        Title: { type: "string" },
                        Modified: { type: "date" },
                        CARID: { type: "string" },
                        Phase1: { type: "string" },
                        Phase2: { type: "string" },
                        Phase3: { type: "string" }
                    }
                }
            }
        }
    });
});
4

0 回答 0