Browse Source

Fix singleSelect state field is 'undefined' error.

zhixin 11 years ago
parent
commit
9a4d7a48ca
2 changed files with 6 additions and 3 deletions
  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>
                     <h2 id="single-checkbox-table">Single Checkbox</h2>
                 </div>
                 </div>
                 <div class="bs-example">
                 <div class="bs-example">
-                    <table id="table-radio" data-toggle="table" data-url="data1.json" data-height="246" data-click-to-select="true" data-single-select="true">
+                    <table data-toggle="table" data-url="data1.json" data-height="246" data-click-to-select="true" data-single-select="true">
                         <thead>
                         <thead>
                         <tr>
                         <tr>
                             <th data-field="state" data-checkbox="true"></th>
                             <th data-field="state" data-checkbox="true"></th>

+ 5 - 2
src/bootstrap-table.js

@@ -244,8 +244,10 @@
                 text += that.getCaretHtml();
                 text += that.getCaretHtml();
             }
             }
 
 
-            if (column.checkbox && !that.options.singleSelect) {
-                text = '<input name="btSelectAll" type="checkbox" />';
+            if (column.checkbox) {
+                if (!that.options.singleSelect) {
+                    text = '<input name="btSelectAll" type="checkbox" />';
+                }
                 that.header.stateField = column.field;
                 that.header.stateField = column.field;
             }
             }
             if (column.radio) {
             if (column.radio) {
@@ -718,6 +720,7 @@
 
 
             that.$selectAll.prop('checked', checkAll);
             that.$selectAll.prop('checked', checkAll);
             row[that.header.stateField] = checked;
             row[that.header.stateField] = checked;
+            console.log(that.header.stateField, row);
             that.trigger(checked ? 'check' : 'uncheck', row);
             that.trigger(checked ? 'check' : 'uncheck', row);
 
 
             if (that.options.singleSelect) {
             if (that.options.singleSelect) {