examples/bootstrapTable/main.js
function setRandomData(data){

    // Include each key with a small chance
    var randomKeys = Object.keys(data[0]).filter(function(d){
          return Math.random() < 0.5;
        }),

        // Make a copy of the objects with only the
        // random keys included.
        dataWithRandomKeys = data.map(function (d) {
          var e = {};
          randomKeys.forEach(function (key) {
            e[key] = d[key];
          });
          return e;
        }),

        // Include each element with a small chance
        randomSample = dataWithRandomKeys.filter(function(d){
          return Math.random() < 0.1;
        });

    // Update the table with the random data.
    table.set({
      data: randomSample,
      columns: randomKeys.map(function (key) {
        return {
          title: capitalize(key),
          property: key
        };
      })
    });
  }
function setRandomData(data){

    // Include each key with a small chance
    var randomKeys = Object.keys(data[0]).filter(function(d){
          return Math.random() < 0.5;
        }),

        // Make a copy of the objects with only the
        // random keys included.
        dataWithRandomKeys = data.map(function (d) {
          var e = {};
          randomKeys.forEach(function (key) {
            e[key] = d[key];
          });
          return e;
        }),

        // Include each element with a small chance
        randomSample = dataWithRandomKeys.filter(function(d){
          return Math.random() < 0.1;
        });

    // Update the table with the random data.
    table.set({
      data: randomSample,
      columns: randomKeys.map(function (key) {
        return {
          title: capitalize(key),
          property: key
        };
      })
    });
  }
function setRandomData ( data ) { // Include each key with a small chance var randomKeys = Object . keys ( data [ 0 ] ) . filter ( function ( d ) { return Math . random ( ) < 0.5 ; } ) , // Make a copy of the objects with only the // random keys included. dataWithRandomKeys = data . map ( function ( d ) { var e = { } ; randomKeys . forEach ( function ( key ) { e [ key ] = d [ key ] ; } ) ; return e ; } ) , // Include each element with a small chance randomSample = dataWithRandomKeys . filter ( function ( d ) { return Math . random ( ) < 0.1 ; } ) ; // Update the table with the random data. table . set ( { data : randomSample , columns : randomKeys . map ( function ( key ) { return { title : capitalize ( key ) , property : key } ; } ) } ) ; }
Sets a random sample of rows and columns on the table, for checking that the table responds properly.
Sets a random sample of rows and columns on the table for checking that the table responds properly .