使用ECMA从SharePoint欢迎页面查询两个不同列表时出现问题
trouble querying 2 different lists from a SharePoint welcome page using ECMA
我的方法在这里不起作用。我在SharePoint 2010文档集的欢迎页面上,并已将我的脚本放置在内容编辑器Web部件CEWP中。使用以下代码,我得到了一个jquery/javascript块。我可以从两个不同的代码块中获得一组或另一组值,但不能同时获得。因此,我在两个查询中复制了一些代码行,这似乎会导致冲突,但我不确定我可以更改什么来使两个集合都是唯一的,或者两者之间发生了什么冲突。非常感谢任何指导。我现在只是在兜圈子。谢谢-dave
我使用的两个块看起来像这样,但在listName上不同。也许这个页面只能支持其中一个?
$(document).ready(function () {
$().SPServices({
operation: "GetListItems",
async: false,
CAMLRowLimit: 2000,
listName: "Personnel Management",
completefunc: fnCallBack
});
});
function fnCallBack(xData, Status) {
var index = 0;
$documentListtable = $("#documentListtable");
//Navigate through the XML
$(xData.responseXML).find("z'':row, row").each(function () {
//Get the values to a local variable
var _url = $(this).attr("ows_FileRef").split(";#")[1];
var _name = $(this).attr("ows_LinkFilename");
;
var _author = $(this).attr("ows_Editor").split(";#")[1];
var modifiedOn = $(this).attr("ows_Modified");
var _TrainingStatus = $(this).attr("ows_Training_x0020_Certificates");
//Create clone of the table row
var $row = $("#templates").find(".row-template").clone();
//Add values to the column based on the css class
$row.find(".DocumentName").html(_pdfLink);
$row.find(".Author").html(_author);
$row.find(".LastModifiedOn").html(modifiedOn);
$row.find(".TrainingStatus").html(_TrainingStatus);
//Change the style for even rows
if (index % 2 == 0) {
$row.addClass("jtable-row-even")
}
if (_TrainingStatus.indexOf("1001") !=-1)
{
index = index + 1;
//add the row to table
$documentListtable.append($row);
}
-
您可以尝试在一个$(document).ready中添加两个SPServices调用,而不是在两个$(document).ready块中添加。一个页面中可能有多个$(document).ready,但您的问题听起来像是在页面加载时只触发了一个SPService调用。
相关文章:
- 如何在Javascript中交换两个列表的子列表
- 使用Jquery比较Javascript中的两个列表/表
- 使用 chui.js $.当有两个列表时,UI 可访问
- 使用 javascript 在两个列表项之间插入下拉项
- jQuery可排序与溢出:隐藏;在两个列表之间
- 遍历两个列表,从第一个列表中获取值,将它们添加到第二个列表中
- AngularUI:在应用过滤器的情况下正确更新两个列表之间的模型
- 检索两个列表,对值进行排序和比较,然后显示所有结果
- 从两个列表中列出一个列表
- 如何在MVC上的两个列表框之间移动项目-JQuery不起作用
- 如何在相反的方向上垂直移动两个列表
- 如何使用JavaScript在两个列表上打印html页面
- JQuery-如何比较两个列表
- 用JavaScript在两个列表之间移动项
- 我如何找到两个列表之间的共同点?
- 在ASP.. NET MVC,我怎么能有列表框来管理两个列表的内容
- 如何在单击时将类删除并添加到两个列表元素中
- 在两个列表中重新排序项目
- Javascript同步两个列表框的滚动
- 如何在javascript中使用getElementByClassName来添加具有相同类名的两个列表中的复选框