@@ -1241,7 +1241,7 @@ angular.module('zeppelinWebApp')
12411241
12421242 var renderTable = function ( ) {
12431243 var html = '' ;
1244- html += '<table class="table table-hover table-condensed">' ;
1244+ html += '<table class="table table-hover table-condensed compact display ">' ;
12451245 html += ' <thead>' ;
12461246 html += ' <tr style="background-color: #F6F6F6; font-weight: bold;">' ;
12471247 for ( var titleIndex in $scope . paragraph . result . columnNames ) {
@@ -1252,7 +1252,7 @@ angular.module('zeppelinWebApp')
12521252 html += ' <tbody>' ;
12531253 for ( var r in $scope . paragraph . result . msgTable ) {
12541254 var row = $scope . paragraph . result . msgTable [ r ] ;
1255- html += ' <tr>' ;
1255+ html += ' <tr>' ;
12561256 for ( var index in row ) {
12571257 var v = row [ index ] . value ;
12581258 if ( getTableContentFormat ( v ) !== 'html' ) {
@@ -1268,14 +1268,68 @@ angular.module('zeppelinWebApp')
12681268 html += '</table>' ;
12691269
12701270 angular . element ( '#p' + $scope . paragraph . id + '_table' ) . html ( html ) ;
1271+ var dataTableTitle = ( $scope . paragraph . title && $scope . paragraph . title . trim ( ) ) ? $scope . paragraph . title . trim ( ) : $scope . paragraph . id ;
1272+
1273+ var oTable = angular . element ( '#p' + $scope . paragraph . id + '_table' ) . children ( 1 ) . DataTable ( {
1274+ paging : false ,
1275+ info : false ,
1276+ autoWidth : true ,
1277+ lengthChange : false ,
1278+ language : {
1279+ search : '_INPUT_' ,
1280+ searchPlaceholder : 'Search records'
1281+ } ,
1282+ dom : "<'row'<'col-sm-12't>>" ,
1283+ buttons : [
1284+ {
1285+ extend : 'csvHtml5' ,
1286+ text : 'TSV' ,
1287+ className : 'btn btn-default btn-sm' ,
1288+ title : dataTableTitle ,
1289+ fieldSeparator : '\t' ,
1290+ extension : '.tsv' ,
1291+ exportOptions : {
1292+ modifier : {
1293+ search : 'none'
1294+ }
1295+ }
1296+ } ,
1297+ {
1298+ extend : 'csvHtml5' ,
1299+ text : 'CSV' ,
1300+ className : 'btn btn-default btn-sm' ,
1301+ title : dataTableTitle ,
1302+ extension : '.csv' ,
1303+ exportOptions : {
1304+ modifier : {
1305+ search : 'none'
1306+ }
1307+ }
1308+ }
1309+ ]
1310+
1311+ } ) ;
1312+
1313+ if ( $ ( '#' + $scope . paragraph . id + '_switch' ) . parent ( ) . parent ( ) . find ( ".btn-group" ) . length <= 2 ) {
1314+ oTable . buttons ( 0 , null ) . containers ( ) . appendTo ( '#' + $scope . paragraph . id + '_switch' ) ;
1315+ }
1316+
1317+ $ ( '#' + $scope . paragraph . id + '_search_input' ) . keyup ( function ( ) {
1318+ oTable . search ( $ ( this ) . val ( ) ) . draw ( ) ;
1319+ } ) ;
1320+ //
1321+
12711322 if ( $scope . paragraph . result . msgTable . length > 10000 ) {
12721323 angular . element ( '#p' + $scope . paragraph . id + '_table' ) . css ( 'overflow' , 'scroll' ) ;
12731324 // set table height
12741325 var height = $scope . paragraph . config . graph . height ;
12751326 angular . element ( '#p' + $scope . paragraph . id + '_table' ) . css ( 'height' , height ) ;
12761327 } else {
12771328 var dataTable = angular . element ( '#p' + $scope . paragraph . id + '_table .table' ) ;
1329+ var tableHead = dataTable . offset ( ) . top ;
12781330 dataTable . floatThead ( {
1331+ position :'fixed' ,
1332+ top : tableHead + 5000 ,
12791333 scrollContainer : function ( dataTable ) {
12801334 return angular . element ( '#p' + $scope . paragraph . id + '_table' ) ;
12811335 }
0 commit comments