[英]Pentaho - how to get the index of selected component?
我正在嘗試使用CDE Dashboard
Select Component
來獲取所選元素的索引。
這很簡單:
SELECT id, username FROM table1
-- this feeds the Select Component
我將“值作為ID”設置為FALSE
,因此該下拉列表將顯示username
,並將返回Select Component
的Parameter
字段中定義的ID
。
我需要編寫一些JavaScript代碼來從selected選項讀取兩個值( ID
和username
),並且我已經使用this.selectedIndex
嘗試過它,但它始終返回-1
。
如果可以獲取索引,則可以遍歷resultSet
對象並獲取所有列。
也嘗試過使用JQuery,但我不是專家,盡管我嘗試過使用:
$( "#my_select_component" ).val()
而且沒有用
如果有更簡單的方法可以實現這一目標,我將不勝感激並提供反饋。
我結束了這個:
在my_select_component的PreChange中:
function f(){
$("#my_select_component").on("change", function() {
Dashboards.setParameter(
"my_parameter_to_update_titles",
$(this).find(":selected")[0].innerText
);
});
}
我使用以下代碼獲取下拉列表中所選項目的id
:
function f(value) {
Dashboards.log(value);
return value;
}
代碼位於我的“ Select Component
Pre Change
屬性中(請注意,“ Pre Change
屬性是CDE
中“ Advanced Properties
視圖的一部分)。
Pre Change
組件之前會觸發Pre Change
代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.