我有一个查询SharePoint列表的JavaScript文件。列类型是名为Devicetype的Choice列,而不是返回信息列表,它返回[object Object],如屏幕抓取所示。
我想知道它是否是var查询字符串?
var query = "http://collaboration-dev.norgine.com/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&$filter=Id eq " + window.DeviceId + "";
它将结果返回到我在JavaScript下面包含的HTML文件。
function getDeviceDetails() {
var txtTitle = "";
var txtOverview = "";
//var txtAccessories = "";
var txtDeviceType = "";
var tempLCS2 = "";
var query = "http://collaboration-dev.norgine.com/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&$filter=Id eq " + window.DeviceId + "";
var call = $.ajax({
url: query,
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function(data, textStatus, jqXHR) {
$.each(data.d.results, function(index, item) {
var tempID = item.Id;
var tempTitle = item.Title;
//var LifeCycleStart = item.DeviceAvailableFrom //moment
//var LifeCycleStart = moment(item.DeviceAvailableFrom, "MM-DD-YYYY");
var date = item.DeviceAvailableFrom;
//var LifeCycleStart = moment(date).format('DD-MM-YYYY');
var LifeCycleStart = String.format('{0:dd}-{0:MM}-{0:yyyy}', new Date(item.DeviceAvailableFrom));
//var LifeCycleStart=new Date();
//LifeCycleStart.toString('dddd,MMM,yyyy');
var LifeCycleStatus = item.LifeCycleStatusValue;
var DeviceOverView = item.Description;
//var AccessDetails = item.Accessorries;
var DeviceKind = item.Devicetype;
txtTitle = "<p>" + LifeCycleStart + "</p><p>" + LifeCycleStatus + "</p>";
txtOverview = "<p>" + DeviceOverView + "</p>";
//txtAccessories = "<p>" + Accessorries + "</p>";
txtDeviceType = "<p>" + DeviceKind + "</p>";
});
$('#devicedetails').append($(txtTitle)); //moment
$('#deviceoverview').append($(txtOverview));
$('#devicekind').append($(txtDeviceType));
//$('#deviceacc').append($(txtAccessories));
});
call.fail(function(jqXHR, textStatus, errorThrown) {
alert("Error retrieving data: " + jqXHR.responseText);
});
}
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<script src="/jquery-1.10.1.min.js"></script>
<script src="/it/SystemInventory/SiteAssets/scripts/moment.min.js"></script>
<script src="/sites/it/SystemInventory/SiteAssets/getDevices.js"></script>
<script src="/sites/it/SystemInventory/SiteAssets/getDeviceDetails.js"></script>
<script src="/sites/it/SystemInventory/SiteAssets/getDeviceKnownIssues.js"></script>
<script type="text/javascript">
function parseQueryString(queryString) {
var params = {},
queries, temp, i, l;
queries = queryString.split("&");
for (i = 0, l = queries.length; i < l; i++) {
temp = queries[i].split('=');
params[temp[0]] = temp[1];
}
return params;
}
$(document).ready(function() {
function getDeviceID() {
if (typeof parseQueryString === "function") {
if (window.location.href.indexOf("?") >= 0) {
var qs = parseQueryString(window.location.href.split("?")[1])
window.DeviceId = qs.did;
getDeviceDetails();
getDeviceKnownIssues();
}
}
}
getDeviceID();
getDevices();
});
</script>
</head>
<style type="text/css">
.tg {
border-collapse: collapse;
border-spacing: 0;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 5px;
border- style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
.tg .tg-yw4l {
vertical-align: top
}
</style>
<table class="tg">
<tr>
<td class="tg-yw4l">
<h1>Devices</h1>
<div id="devices">
</div>
</td>
<td class="tg-yw4l">
<h1>Device Details</h1>
<div id="devicedetails">
</div>
</td>
<td class="tg-yw4l">
<h1>Device Overview</h1>
<div id="deviceoverview">
<div id="devicekind">
</div>
</td>
</tr>
</table>
<table class="tg">
<tr>
<td class="tg-yw4l">
<h1>Accessories</h1>
<div id="deviceacc">
</div>
</td>
<td class="tg-yw4l">
<h1>Typical Usage</h1>
<div id=" ">
</div>
</td>
<td class="tg-yw4l">
<h1>Another Table</h1>
<div id=" ">
</div>
</td>
</tr>
</table>
<!--[if gte mso 9]>
<xml>
<mso:CustomDocumentProperties>
<mso:_dlc_DocId msdt:dt="string">ITDOCUMENTS-135-47</mso:_dlc_DocId>
<mso:_dlc_DocIdItemGuid msdt:dt="string">1d6007ea-9e58-4298-b2d6-
9196e2678ea3</mso:_dlc_DocIdItemGuid>
<mso:_dlc_DocIdUrl msdt:dt="string">http://collaboration-
dev.norgine.com/sites/it/SystemInventory/_layouts/DocIdRedir.aspx?
ID=ITDOCUMENTS-135-47, ITDOCUMENTS-135-47</mso:_dlc_DocIdUrl>
</mso:CustomDocumentProperties>
</xml>
<![endif]-->
答案 0 :(得分:0)
IT与内容类型有关。如果我将列从Drop Down更改为Free Text并更改$(&#39;#devicekind&#39;)。append(txtDeviceType [0]); to $(&#39;#devicekind&#39;)。append(txtDeviceType);它返回正确的结果。