1

我正在尝试设置两个下拉菜单。一个中的值取决于另一个的当前值。如何链接它们,当我在一个下拉菜单中更改所选值时,它会自动更新另一个下拉菜单?

谢谢。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
 <head>
<title>User Stories By Iteration</title>
 <meta name="Name" content="App Example: User Stories Table" />
 <script type="text/javascript" src="/apps/1.32/sdk.js"></script>
 <script type="text/javascript">

 var rallyDataSource;
 var relDropdown;
var table;
var relDropdown2;

function onReleaseSelected(releases, eventArgs) {
   var queryConfig = {
     type : 'testset',
     attribute : 'Name',
     query: '(Release.Name = "' + releases.getDisplayedValue() + '")'
  };
   relDropdown2 = new rally.sdk.ui.ObjectDropdown(queryConfig, rallyDataSource);
   relDropdown2.display(document.getElementById("releaseDiv2"));
 }

 function onLoad() {
   rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
                                '__PROJECT_OID__',
                                '__PROJECT_SCOPING_UP__',
                                '__PROJECT_SCOPING_DOWN__');
  var relConfig = {};
   relDropdown = new rally.sdk.ui.ReleaseDropdown(relConfig, rallyDataSource);
   relDropdown.display(document.getElementById("releaseDiv"), onReleaseSelected);
 }

 rally.addOnLoad(onLoad);
  </script>

</head>
<body>
<div>
 <div id="releaseDiv"></div>
 <div id="releaseDiv2"></div>
 </div>
<br/><br/>
</body>
 </html> 
4

1 回答 1

1

SDK 1.x 下拉菜单在呈现后无法刷新其值。但是,您可以做的是销毁第二个下拉列表并重新创建它以响应第一个下拉列表的更改事件。

因此,在您的 onReleaseSelected 中,只需在创建和显示新代码之前添加以下代码:

if(relDropdown2) {
    relDropdown2.destroy();
}
于 2012-11-03T14:43:25.960 回答