我使用SPServices - GetListItems ajax从SharePoint 2010检索Kendo Grid的数据。然后我将Title绑定到URL模板。这可以正常工作(除了一个网格的链接输出生成跨站点脚本错误,点击该项目。这很奇怪,因为页面和链接在同一个站点)。
我更愿意链接到基础工作流实例,但无法找到GetListItems返回的任何结果或基础XML数据(通过Stramit Caml Viewer查看)中所需的唯一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" }
}
}
}
}
});
});