集会:如何在更改另一个下拉菜单后自动更新下拉列表?

时间:2012-11-02 16:18:05

标签: drop-down-menu rally

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

感谢。

<!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> 

1 个答案:

答案 0 :(得分:1)

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

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

if(relDropdown2) {
    relDropdown2.destroy();
}