浏览代码

Merge pull request #663 from djhvscf/master

Added Unique Id identifier for each row
文翼 10 年之前
父节点
当前提交
afcca02d4c

+ 7 - 22
docs/_i18n/en/documentation/table-options.md

@@ -310,6 +310,13 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>Indicate which field is an identity field.</td>
     </tr>
     <tr>
+        <td>uniqueId</td>
+        <td>data-unique-id</td>
+        <td>String</td>
+        <td>undefined</td>
+        <td>Indicate an unique identifier for each row.</td>
+    </tr>
+    <tr>
         <td>cardView</td>
         <td>data-card-view</td>
         <td>Boolean</td>
@@ -407,28 +414,6 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         T/t: It will toggle the table view if the showToggle option is enabled
         P/p: It will fires the pagination switch if the showPaginationSwitch is enabled.</td>
     </tr>
-	<tr>
-        <td>stateSave</td>
-        <td>data-state-save</td>
-        <td>Boolean</td>
-        <td>false</td>
-        <td>True to save the state of a table (its paging position, ordering state, records per page).</td>
-    </tr>
-	<tr>
-        <td>stateSaveExpire</td>
-        <td>data-state-save-expire</td>
-        <td>String</td>
-        <td>'2h'</td>
-        <td>You must set this property if stateSave is enable to know when will expire the cookie created. Must use this format: 'number{letter}' like '2h', in the letter position
-		you can use: 's','mi','h','d','m','y', these means: 'seconds', 'minutes', 'hours', 'days', 'months', 'years'.</td>
-    </tr>
-	<tr>
-        <td>stateSaveIdTable</td>
-        <td>data-state-save-id-table</td>
-        <td>String</td>
-        <td>''</td>
-        <td>You must set this property if stateSave is enable to sets an unique cookie with an identifier for each table in your page or project. You must set this property because we need create cookies with an identifier.</td>
-    </tr>
     <tr>
         <td>rowStyle</td>
         <td>data-row-style</td>

+ 7 - 22
docs/_i18n/es/documentation/table-options.md

@@ -300,6 +300,13 @@ Las opciones de la tabla están definidas en `jQuery.fn.bootstrapTable.defaults`
         <td>Indica cuál campo es el identificador.</td>
     </tr>
     <tr>
+        <td>uniqueId</td>
+        <td>data-unique-id</td>
+        <td>String</td>
+        <td>undefined</td>
+        <td>Indica un único id para cada fila.</td>
+    </tr>
+    <tr>
         <td>cardView</td>
         <td>data-card-view</td>
         <td>Boolean</td>
@@ -394,28 +401,6 @@ Las opciones de la tabla están definidas en `jQuery.fn.bootstrapTable.defaults`
         T/t: Se cambiará de vista si la opción showToggle está habilitada
         P/p: Se ocultara/mostrará la paginación si la opción showPaginationSwitch está habilitada.</td>
     </tr>
-	<tr>
-        <td>stateSave</td>
-        <td>data-state-save</td>
-        <td>Boolean</td>
-        <td>false</td>
-        <td>True para guardar el estado de la tabla (la posición de la paginación, ordenamiento, filas por página).</td>
-    </tr>
-	<tr>
-        <td>stateSaveExpire</td>
-        <td>data-state-save-expire</td>
-        <td>String</td>
-        <td>'2h'</td>
-        <td>Indique la propiedad para saber cuando expirará la cookie creada. Use este formato: 'numero{letra}' por ejemplo: '2h', en la posicióon de la letra
-		se puede usar: 's','mi','h','d','m','y', esto significa: 'segundos', 'minutos', 'horas', 'días', 'meses', 'años'.</td>
-    </tr>
-	<tr>
-        <td>stateSaveIdTable</td>
-        <td>data-state-save-id-table</td>
-        <td>String</td>
-        <td>''</td>
-        <td>Debe indicar la propiedad si la stateSave está habilitado. Este será el identificador para cookie guardada por tabla en su página o proyecto.</td>
-    </tr>
     <tr>
         <td>rowStyle</td>
         <td>data-row-style</td>

+ 2 - 0
src/bootstrap-table.js

@@ -171,6 +171,7 @@
         smartDisplay: true,
         minimumCountColumns: 1,
         idField: undefined,
+        uniqueId: undefined,
         cardView: false,
         trimOnSearch: true,
         clickToSelect: false,
@@ -1233,6 +1234,7 @@
                 sprintf(' id="%s"', $.isArray(item) ? undefined : item._id),
                 sprintf(' class="%s"', style.classes || ($.isArray(item) ? undefined : item._class)),
                 sprintf(' data-index="%s"', i),
+                sprintf(' data-unique-id="%s"', item[this.options.uniqueId]),
                 '>'
             );
 

+ 30 - 0
src/extensions/cookie/README.md

@@ -0,0 +1,30 @@
+# Table Cookie
+
+Use Plugin: [bootstrap-table-cookie](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/cookie)
+
+## Usage
+
+```html
+<script src="extensions/cookie/bootstrap-table-cookie.js"></script>
+```
+
+## Options
+
+### stateSave
+
+* type: Boolean
+* description: Set true to save the state of a table (its paging position, ordering state, records per page).
+* default: `false`
+
+### stateSaveExpire
+
+* type: String
+* description: You must set this property if stateSave is enable to know when will expire the cookie created. Must use this format: 'number{letter}' like '2h', in the letter position
+               		you can use: 's','mi','h','d','m','y', these means: 'seconds', 'minutes', 'hours', 'days', 'months', 'years'.
+* default: `2h`
+
+### stateSaveIdTable
+
+* type: String
+* description: You must set this property if stateSave is enable to sets an unique cookie with an identifier for each table in your page or project. You must set this property because we need create cookies with an identifier.
+* default: ``

+ 2 - 0
src/extensions/cookie/bootstrap-table-cookie.js

@@ -1,5 +1,7 @@
 /**
  * @author: Dennis Hernández
+ * @webSite: http://djhvscf.github.io/Blog
+ *
  * @update zhixin wen <wenzhixin2010@gmail.com>
  */