ソースを参照

Add 'idField' option.

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

+ 6 - 0
docs/docs.js

@@ -132,6 +132,12 @@ $(function () {
                 type: 'Boolean',
                 description: 'True to show the columns drop down list.',
                 'default': 'false'
+            },
+            {
+                name: 'idField',
+                type: 'String',
+                description: 'Indicate which field is an identity field.',
+                'default': 'undefined'
             }
         ]
     });

+ 1 - 2
docs/examples.html

@@ -271,11 +271,10 @@
                     <h1 id="show-columns-table">Show Columns Table</h1>
                 </div>
                 <div class="bs-example">
-                    <table data-toggle="table" data-url="data3.json" data-height="246" data-show-columns="true">
+                    <table data-toggle="table" data-url="data3.json" data-height="246" data-show-columns="true" data-id-field="id">
                         <thead>
                         <tr>
                             <th data-field="state" data-radio="true"></th>
-                            <th data-field="id">ID</th>
                             <th data-field="name">Name</th>
                             <th data-field="price">Price</th>
                             <th data-field="column1">Columns1</th>

+ 2 - 0
src/bootstrap-table.js

@@ -64,6 +64,7 @@
         selectItemName: 'btSelectItem',
         showHeader: true,
         showColumns: false,
+        idField: undefined,
 
         formatRecordsPerPage: function(pageNumber) {
             return sprintf('%s records per page', pageNumber);
@@ -540,6 +541,7 @@
                             sprintf(' data-index="%s"', i) +
                             sprintf(' name="%s"', that.options.selectItemName) +
                             sprintf(' type="%s"', type) +
+                            sprintf(' value="%s"', item[that.options.idField]) +
                             sprintf(' checked="%s"', value ? 'checked' : undefined) + ' />',
                         '</td>'].join('');
                 }