簡體   English   中英

Pentaho-如何獲取所選組件的索引?

[英]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 ComponentParameter字段中定義的ID

我需要編寫一些JavaScript代碼來從selected選項讀取兩個值( IDusername ),並且我已經使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM