ソースを参照

Fix #30: getSelections return error when using radio button.

zhixin 11 年 前
コミット
3e90b338cd
2 ファイル変更6 行追加3 行削除
  1. 1 1
      docs/examples.html
  2. 5 2
      src/bootstrap-table.js

+ 1 - 1
docs/examples.html

@@ -421,7 +421,7 @@
                     <h2 id="single-checkbox-table">Single Checkbox</h2>
                 </div>
                 <div class="bs-example">
-                    <table data-toggle="table" data-url="data1.json" data-height="246" data-click-to-select="true" data-single-select="true">
+                    <table id="table-radio" data-toggle="table" data-url="data1.json" data-height="246" data-click-to-select="true" data-single-select="true">
                         <thead>
                         <tr>
                             <th data-field="state" data-checkbox="true"></th>

+ 5 - 2
src/bootstrap-table.js

@@ -202,6 +202,9 @@
         });
         this.options.columns = $.extend(true, columns, this.options.columns);
         $.each(this.options.columns, function(i, column) {
+            if (i === 0 && column.radio) {
+                that.options.singleSelect = true;
+            }
             that.options.columns[i] = $.extend({}, BootstrapTable.COLUMN_DEFAULTS, column);
         });
 
@@ -718,10 +721,10 @@
             that.trigger(checked ? 'check' : 'uncheck', row);
 
             if (that.options.singleSelect) {
-                that.$selectItem.filter(':checked').not(this).each(function() {
-                    $(this).prop('checked', false);
+                that.$selectItem.not(this).each(function() {
                     that.data[$(this).data('index')][that.header.stateField] = false;
                 });
+                that.$selectItem.filter(':checked').not(this).prop('checked', false);
             }
 
 //            $(this).parents('tr')[checked ? 'addClass' : 'removeClass']('selected');