Pentaho 6.1-如何通过JavaScript生成的两个字段过滤表组件的结果?

时间:2019-10-02 15:31:45

标签: javascript jquery pentaho pentaho-cde pentaho-ctools

我有一个表组件,可通过CDA执行SQL查询。

如何基于两个输入字段过滤结果,第一个输入用于第一列的行,第二个输入用于第四列的行?

我在表组件的后执行中使用以下Javascript函数创建了字段:

function f() {
    $(document).ready(function () {
        // Setup - add a text input to each footer cell
        var arrayColumns = ['Application ID', 'Object Type'];

        $('#example thead th').each(function () {
            var testo = $('#example thead th').eq($(this).index()).html();
            var title = $('#example thead th').eq($(this).index()).text();
            if (arrayColumns.indexOf(title) > -1) {
                $(this).html(testo + '<br><input type="text" placeholder="Search ' + title + '">');
            }
        });

        // DataTable
        var table = $('#example').DataTable();

        // Apply the search.
        table.columns().eq(0).each(function (colIdx) {
            $('input', table.column(colIdx).header()).on('keyup change clear', function () {
                table
                    .column(colIdx)
                    .search(this.value)
                    .draw();
            });
            // If you click in the field, it doesn't sort the results in the column in ascending/descending order.
            $('input', table.column(colIdx).header()).on('click', function (e) {
                e.stopPropagation();
            });
        });
    });
}

0 个答案:

没有答案