2017-06-15 176 views
-1

我有一个查询SharePoint列表的JavaScript文件。我正在查询两个下拉列表。第一个 - LifeCycleStatus - 恢复正常,但优先级下拉回到screen grab [object OBJECT]。我认为它与var查询字符串有关。我已经添加了“优先级”列到了var查询,但它似乎并没有被作任何差别Javascript var查询返回[对象对象]

var query = "http://collaboration- 
    de.vxxx.com/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&Priority&$filter=Id eq " + window.DeviceId + ""; 

完整的JavaScript如下:

function getDeviceDetails() { 
var txtTitle = ""; 
var txtOverview = ""; 
var txtAccessories = ""; 
var txtDevicetype = ""; 
var txtTypicalDeviceUsage =""; 
var txtKnownSystemIssues =""; 
var txtLifeCycles = ""; 
var txtTrafficlight = ""; 
    var tempLCS2 = ""; 

var query = "http://collaboration-dev.xxx/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&Priority&$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; 



     var LifeCycleStatus = item.LifeCycleStatusValue; 
     var DeviceOverView = item.Description; 
     var AccessDetails = item.Accessories; 
     var DeviceKind = item.Devicetype; 
     var Usage = item.TypicalUsage; 
     var DevicePriority = item.Priority; 


     txtTitle = "<p>" + LifeCycleStart + "</p><p>" + LifeCycleStatus + "</p>"; 
     txtOverview = "<p>" + DeviceOverView + "</p>"; 
     txtAccessories = "<p>" + AccessDetails + "</p>"; 
     txtDevicetype = "<p>" + DeviceKind + "</p>"; 
     txtTypicalDeviceUsage = "<p>" + Usage + "</p>"; 
     txtTrafficlight = "<p>" + DevicePriority + "</p>"; 
     // txtKnownSystemIssues = "<p>" + KnownSystem + "</p>" 
    }); 
    $('#devicedetails').append($(txtTitle)); 
    $('#deviceoverview').append($(txtOverview)); 
    $('#devicekind').append(txtDevicetype); 
    $('#deviceacc').append(txtAccessories); 
    $('#deviceuse').append(txtTypicalDeviceUsage); 
    $('#devicestatus').append(txtTrafficlight); 

}); 





call.fail(function (jqXHR,textStatus,errorThrown){ 
    alert("Error retrieving data: " + jqXHR.responseText); 
}); 

}

+0

因为提取的值是一个对象,当你试图将对象转换为字符串时,它使用'.toString'方法完成,该方法返回'[object Object]' – Rajesh

+0

这很奇怪,因为它返回的LifeCycleStatus下拉列结果正确吗? – Dazza

+0

你会建议Rajesh? – Dazza

回答

0

“优先级”和“LifeCycleStatus”包含一个对象。您可以使用调试器/控制台来查看对象是什么 - 我敢打赌它包含一个带有值的字符串,以及值的内部标识符,可能还有其他的东西。将对象转换为字符串将返回“[object Object]”。

“优先价值”和“LifeCycleStatus 价值”可能是速记的字符串值。