我正在为我的自定义实体http://msdn.microsoft.com/en-us/library/hh223541.aspx
调整此处的REST示例它检索并显示除money之外的所有属性的表。也就是说,如果我请求的属性不包含表格中显示的money类型的属性。一旦我添加了money属性,就不会显示任何内容。下面是我的自定义HTML。我正在使用样本与解决方案中包含的相同SDK.OptionSetSample.js。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contacts Page</title>
<script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script src="Scripts/json2.js" type="text/javascript"></script>
<script src="Scripts/SDK.OptionSetSample.js" type="text/javascript"></script>
<script src="Scripts/SDK.MetaData.js" type="text/javascript"></script>
<script src="Scripts/SDK.REST.js" type="text/javascript"></script>
<link href="Styles/OptionSetSample.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var attributes = [
"new_revenuesportspartnershipsId",
"new_name",
"new_PledgeorCash",
"new_Designation",
"new_DonorStatus"
, "new_FY2011"
];
var ContactListTableData = {
Id: "ContactList",
BodyId: "ContactListBody",
CheckboxColumn: true,
SearchFieldId: "SearchString",
CreateButtonId: "createContact",
DeleteButtonId: "deleteSelectedRecords",
Columns: [
{ Name: "new_name" },
{ Name: "new_PledgeorCash" },
{ Name: "new_Designation" },
{ Name: "new_DonorStatus" }
,{ Name: "new_FY2011" }
]
};
var CurrentContactForm = {
Id: "CurrentContact",
SaveButtonId: "SaveCurrentContact",
CloseFormControlId: "closeFormSpan"
};
window.onload = function () {
SDK.OptionSetSample.Entity = "new_revenuesportspartnerships";
SDK.OptionSetSample.Columnset = attributes;
SDK.OptionSetSample.PrimaryIdAttribute = "new_revenuesportspartnershipsId";
SDK.OptionSetSample.TextSearchAttribute = "new_name";
SDK.OptionSetSample.PrimaryAttribute = "new_name";
SDK.OptionSetSample.TableData = ContactListTableData,
SDK.OptionSetSample.FormData = CurrentContactForm;
//Get the Attribute metadata
SDK.OptionSetSample.getAttributeMetadataCollection.Execute();
}
</script>
</head>
<body>
<ul id="message">
</ul>
<div>
<button id="createContact">
Create</button>
<button id="deleteSelectedRecords" disabled="disabled">
Delete Selected Contacts</button>
<span id="searchBy">Search by Full Name :</span><input id="SearchString" type="text" />
<table id="ContactList" class="RecordList" />
</div>
<div id="CurrentContact" class="editForm">
<span id="closeFormSpan" class="closeFormSpan">X</span>
<!-- Only Boolean, Picklist, Status, and String attribute types are supported in this sample.-->
<div id="new_nameField">
</div>
<div id="new_PledgeorCashField">
</div>
<button id="SaveCurrentContact" disabled="disabled">
Save</button>
</div>
</body>
</html>
答案 0 :(得分:2)
示例脚本对于Money看起来像这样,因为它已经有一个案例:
case "Money":
case "Integer":
var Value = record[AttributeMetadata.SchemaName];
record[AttributeMetadata.SchemaName] = {};
record[AttributeMetadata.SchemaName].Value = Value;
record[AttributeMetadata.SchemaName].isDirty = false;
在概述的两种情况下,Integer将正常工作,因为它是一种原始类型,因此将实际数值返回到record[AttributeMetadata.SchemaName].Value
然而,钱类型是一个复杂的对象,所以它被分配给同一个变量,但实际上并没有给你它代表的对象,这就是它没有显示的对象。实际上,您需要在结尾处再使用.value
来检索它所代表的数值。
将开关更改为:
case "Integer":
var Value = record[AttributeMetadata.SchemaName];
record[AttributeMetadata.SchemaName] = {};
record[AttributeMetadata.SchemaName].Value = Value;
record[AttributeMetadata.SchemaName].isDirty = false;
case "Money":
var Value = record[AttributeMetadata.SchemaName];
record[AttributeMetadata.SchemaName] = {};
record[AttributeMetadata.SchemaName].Value = Value.value;
record[AttributeMetadata.SchemaName].isDirty = false;
或当您将money属性放入表格时,请确保显示的值为record[AttributeMetadata.SchemaName].Value.value
我认为它是value
的小写,可能是Value
希望这是有道理的。