cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <table id='table'></table>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
         <form class="form-horizontal">
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 1</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col1" id="col1">
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 2</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col2" id="col2">
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 3</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col3" id="col3">
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 4</label>
              <div class="col-sm-10 radio">
                <label class="radio-inline"> 
                  <input type="radio" name="col4" value="0"> 0
                </label>
                <label class="radio-inline"> 
                  <input type="radio" name="col4" value="1"> 1
                </label>
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 5</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col5" id="col5">
              </div>
           </div>
         </form>
      </div>

      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
            
          
!
            
              .update, .remove {
  margin-left: 5px;
  margin-right: 5px;
}

.remove {
  color: rgba(215,38,54,0.85);
}
            
          
!
            
              // buid data for table
function buildTable(cells, rows) {
    var i, j, row,
        data = [];

    for (i = 0; i < rows; i++) {
        row = {};
        row['col1'] = 'col1 - ' + i;
        row['col2'] = 'col2 - ' + i;
        row['col3'] = 'col3 - ' + i;
        row['col4'] = i%2;
        row['col5'] = 'col5 - ' + i;
        data.push(row);
    }
    return data;
}

// show the data of table in the modal
function showModal($modal, row) {
  // row is the data for the specific row of the table  
    for (var name in row) {
        $modal.find('input:not([type=radio],[type=checkbox])[id="' + name + '"]').val(row[name]);
        $modal.find('input:radio[name="'+name+'"][value="' + row[name] + '"]').prop('checked', true)
    }
    $modal.modal('show');
}

// format of update or delete icons
function actionFormatter(value) {
    return [
        '<a class="update" href="javascript:void(0)" title="修改"><i class="glyphicon glyphicon-edit"></i></a>',
        '<a class="remove" href="javascript:void(0)" title="删除"><i class="glyphicon glyphicon-remove-circle"></i></a>',
    ].join('');
};

var $modal = $('#myModal');

// updata & delete events
window.actionEvents = {
    'click .update': function (e, value, row) {
        showModal($modal, row);
    },
  
    'click .remove': function (e, value, row) {
        if (confirm('really want to delete?')) {
            // ajax delete
        }
    }
};

// modal when hidden, clear the form
$modal.on('hidden.bs.modal', function(event) {
        $modal.find("input:not([type=radio],[type=checkbox]),textarea,select").val('');
        $modal.find('input[type=checkbox], input[type=radio]').prop('checked', false);       
    });

var tableSetting = {
    striped: true,
    pagination: true,
    search: true,
    showToggle: true,
    showRefresh: true,
    showPaginationSwitch: true,
    minimumCountColumns: 2,
    showHeader: true,
    showFooter: true,
    classes: 'table table-hover table-condensed',
    columns: [{
        field: 'col1',
        title: 'Col 1',
        class: '',
    }, {
        field: 'col2',
        title: 'Col 2',
        class: '',
    }, {
        field: 'col3',
        title: 'Col 3',
        class: '',
    }, {
        field: 'col4',
        title: 'Col 4',
        class: '',
    }, {
        field: 'col5',
        title: 'Col 5',
        class: '',
    }, {
                title: 'operation',
                field: 'action',
                width: '7%',
                align: 'center',
                formatter: actionFormatter,
                events: actionEvents
            }],
};

$(function() {
    $('#table').bootstrapTable(tableSetting);
    $('#table').bootstrapTable('load', buildTable(8, 20));
});

$(window).on('resize', function() {
    $('#table').bootstrapTable('resetView');
});


            
          
!
999px
Loading ..................

Console