在Pentaho CDE BI服务器中搜索单个列

时间:2014-10-20 15:40:20

标签: javascript datatables pentaho pentaho-cde

CDE Pentaho中的表组件基于数据表,我想在表https://datatables.net/examples/api/multi_filter.html中实现此功能

$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
        var title = $('#example thead th').eq( $(this).index() ).text();
        $(this).html( '<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 ).footer() ).on( 'keyup change', function () {
            table
                .column( colIdx )
                .search( this.value )
                .draw();
        } );
    } );
} );

我无法让它工作,我得到错误处理组件消息,我尝试将其包含为js片段,作为外部源,在post fetch和post post执行功能中,我认为缺少每个索引列导致了问题,我在输出选项中包含了索引,它也没有用,

我还发现了这个替代http://jsfiddle.net/CmMfJ/2/#collaborate

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

$("#example tfoot th").each( function ( i ) {
  var select = $('<select><option value="">All</option></select>')
    .appendTo( $(this).empty() )
    .on( 'change', function () {
       var term =  $(this).val()!=='' ?   '^'+$(this).val()+'$' : '';
       table.column( i )
          .search(term, true, false )
          .draw();
       } );

  table.column( i ).data().unique().sort().each( function ( d, j ) {
    select.append( '<option value="'+d+'">'+d+'</option>' )
  });
});

我没有得到任何错误的代码,但它不起作用,表没有改变,在这两种情况下在后执行功能我这样做:函数f(){代码},我也改变了变量#example表示我的表名,没有任何效果,任何帮助都会非常感谢,谢谢。

1 个答案:

答案 0 :(得分:0)

您的postExecution方法可能是正确的,但您无法在该div上创建新的DataTable。它已经创建。

如果在执行postExecution期间检查此对象,其中一个字段(无法记住哪个)可以访问您的DataTable对象(示例中的var表)。