浏览代码

Add examples to option api

zhixin 7 年之前
父节点
当前提交
12af026392
共有 1 个文件被更改,包括 140 次插入119 次删除
  1. 140 119
      site/docs/api/table-options.md

+ 140 - 119
site/docs/api/table-options.md

@@ -25,25 +25,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `'table'`
 - **Default:** `'table'`
 
 
-## locale
-
-- **Attribute:** `data-locale`
-
-- **Type:** `String`
-
-- **Detail:**
-
-  Sets the locale to use (i.e. `'zh-CN'`). Locale files must be pre-loaded.
-  Allows for fallback locales, if loaded, in the following order:
-
-  * First tries for the locale as specified,
-  * Then tries the locale with '_' translated to '-' and the region code upper cased,
-  * Then tries the the short locale code (i.e. `'zh'` instead of `'fr-CA'`),
-  * And finally will use the last locale file loaded (or the default locale if no locales loaded).
-
-  If left `undfined` or an empty string, uses the last locale loaded (or `'en-US'` if no locale files loaded).
-
-- **Default:** `undefined`
+- **Example:** [From HTML](https://examples.bootstrap-table.com/#options/from-html.html)
 
 
 ## height
 ## height
 
 
@@ -57,17 +39,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `undefined`
 - **Default:** `undefined`
 
 
-## undefinedText
-
-- **Attribute:** `data-undefined-text`
-
-- **Type:** `String`
-
-- **Detail:**
-
-  Defines the default `undefined` text.
-
-- **Default:** `'-'`
+- **Example:** [Table Height](https://examples.bootstrap-table.com/#options/table-height.html)
 
 
 ## classes
 ## classes
 
 
@@ -77,9 +49,11 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Detail:**
 - **Detail:**
 
 
-  The class name of table. By default, the table is bordered, you can add `'table-no-bordered'` to remove table-bordered style.
+  The class name of table. `'table'`, `'table-bordered'`, `'table-hover'`, `'table-striped'`, `'table-dark'`, `'table-sm'` and `'table-borderless'` can be used. By default, the table is bordered.
+
+- **Default:** `'table table-bordered table-hover'`
 
 
-- **Default:** `'table table-hover'`
+- **Example:** [Table Classes](https://examples.bootstrap-table.com/#options/table-classes.html)
 
 
 ## theadClasses
 ## theadClasses
 
 
@@ -93,29 +67,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `''`
 - **Default:** `''`
 
 
-## sortClass
-
-- **Attribute:** `data-sort-class`
-
-- **Type:** `String`
-
-- **Detail:**
-
-  The class name of the `td` elements which are sorted.
-
-- **Default:** `undefined`
-
-## striped
-
-- **Attribute:** `data-striped`
-
-- **Type:** `Boolean`
-
-- **Detail:**
-
-  Set `true` to stripe the rows.
-
-- **Default:** `false`
+- **Example:** [Thead Classes](https://examples.bootstrap-table.com/#options/thead-classes.html)
 
 
 ## rowStyle
 ## rowStyle
 
 
@@ -130,19 +82,12 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
   * `row`: the row record data.
   * `row`: the row record data.
   * `index`: the row index.
   * `index`: the row index.
 
 
-  Support classes or css. Example usage:
-
-  {% highlight javascript %}
-  function rowStyle(row, index) {
-    return {
-      classes: 'text-nowrap another-class',
-      css: {color: 'blue', 'font-size': '50px'}
-    }
-  }
-  {% endhighlight %}
+  Support classes or css.
 
 
 - **Default:** `{}`
 - **Default:** `{}`
 
 
+- **Example:** [Row Style](https://examples.bootstrap-table.com/#options/row-style.html)
+
 ## rowAttributes
 ## rowAttributes
 
 
 - **Attribute:** `data-row-attributes`
 - **Attribute:** `data-row-attributes`
@@ -160,6 +105,44 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `{}`
 - **Default:** `{}`
 
 
+- **Example:** [Row Attributes](https://examples.bootstrap-table.com/#options/row-attributes.html)
+
+## undefinedText
+
+- **Attribute:** `data-undefined-text`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  Defines the default `undefined` text.
+
+- **Default:** `'-'`
+
+- **Example:** [Undefined Text](https://examples.bootstrap-table.com/#options/undefined-text.html)
+
+## locale
+
+- **Attribute:** `data-locale`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  Sets the locale to use (i.e. `'zh-CN'`). Locale files must be pre-loaded.
+  Allows for fallback locales, if loaded, in the following order:
+
+  * First tries for the locale as specified,
+  * Then tries the locale with '_' translated to '-' and the region code upper cased,
+  * Then tries the the short locale code (i.e. `'zh'` instead of `'fr-CA'`),
+  * And finally will use the last locale file loaded (or the default locale if no locales loaded).
+
+  If left `undfined` or an empty string, uses the last locale loaded (or `'en-US'` if no locale files loaded).
+
+- **Default:** `undefined`
+
+- **Example:** [Table Locale](https://examples.bootstrap-table.com/#options/table-locale.html)
+
 ## sortable
 ## sortable
 
 
 - **Attribute:** `data-sortable`
 - **Attribute:** `data-sortable`
@@ -172,6 +155,22 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `true`
 - **Default:** `true`
 
 
+- **Example:** [Table Sortable](https://examples.bootstrap-table.com/#options/table-sortable.html)
+
+## sortClass
+
+- **Attribute:** `data-sort-class`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  The class name of the `td` elements which are sorted.
+
+- **Default:** `undefined`
+
+- **Example:** [Sort Class](https://examples.bootstrap-table.com/#options/sort-class.html)
+
 ## silentSort
 ## silentSort
 
 
 - **Attribute:** `data-silent-sort`
 - **Attribute:** `data-silent-sort`
@@ -180,10 +179,12 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Detail:**
 - **Detail:**
 
 
-  Set `false` to sort the data silently. This options works when the sidePagination option is set to `'server'`.
+  Set `false` to sort the data with loading message. This options works when the sidePagination option is set to `'server'`.
 
 
 - **Default:** `true`
 - **Default:** `true`
 
 
+- **Example:** [Silent Sort](https://examples.bootstrap-table.com/#options/silent-sort.html)
+
 ## sortName
 ## sortName
 
 
 - **Attribute:** `data-sort-name`
 - **Attribute:** `data-sort-name`
@@ -196,6 +197,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `undefined`
 - **Default:** `undefined`
 
 
+- **Example:** [Sort Name Order](https://examples.bootstrap-table.com/#options/sort-name-order.html)
+
 ## sortOrder
 ## sortOrder
 
 
 - **Attribute:** `data-sort-order`
 - **Attribute:** `data-sort-order`
@@ -208,6 +211,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `'asc'`
 - **Default:** `'asc'`
 
 
+- **Example:** [Sort Name Order](https://examples.bootstrap-table.com/#options/sort-name-order.html)
+
 ## sortStable
 ## sortStable
 
 
 - **Attribute:** `data-sort-stable`
 - **Attribute:** `data-sort-stable`
@@ -220,6 +225,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `false`
 - **Default:** `false`
 
 
+- **Example:** [Sort Stable](https://examples.bootstrap-table.com/#options/sort-stable.html)
+
 ## rememberOrder
 ## rememberOrder
 
 
 - **Attribute:** `data-remember-order`
 - **Attribute:** `data-remember-order`
@@ -228,10 +235,12 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Detail:**
 - **Detail:**
 
 
-  Set true remember the order for each column.
+  Set `true` to remember the order for each column.
 
 
 - **Default:** `false`
 - **Default:** `false`
 
 
+- **Example:** [Remember Order](https://examples.bootstrap-table.com/#options/remember-order.html)
+
 ## customSort
 ## customSort
 
 
 - **Attribute:** `data-custom-sort`
 - **Attribute:** `data-custom-sort`
@@ -240,21 +249,15 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Detail:**
 - **Detail:**
 
 
-  The custom sort function is executed instead of built-in sort function, takes two parameters:
+  The custom sort function is executed instead of built-in sort function, takes three parameters:
 
 
   * `sortName`: the sort name.
   * `sortName`: the sort name.
   * `sortOrder`: the sort order.
   * `sortOrder`: the sort order.
+  * `data`: the rows data.
 
 
-  Example usage:
-
-  {% highlight javascript %}
-  function customSort(sortName, sortOrder) {
-    //Sort logic here.
-    //You must use `this.data` array in order to sort the data. NO use `this.options.data`.
-  }
-  {% endhighlight %}
+- **Default:** `undefined`
 
 
-- **Default:** `$.noop`
+- **Example:** [Custom Order](https://examples.bootstrap-table.com/#options/custom-order.html)
 
 
 ## columns
 ## columns
 
 
@@ -268,6 +271,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `[]`
 - **Default:** `[]`
 
 
+- **Example:** [Table Columns](https://examples.bootstrap-table.com/#options/table-columns.html)
+
 ## data
 ## data
 
 
 - **Attribute:** `-`
 - **Attribute:** `-`
@@ -280,41 +285,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `[]`
 - **Default:** `[]`
 
 
-## totalField
-
-- **Attribute:** `data-total-field`
-
-- **Type:** `String`
-
-- **Detail:**
-
-  Key in incoming json containing `'total'` data .
-
-- **Default:** `'total'`
-
-## dataField
-
-- **Attribute:** `data-data-field`
-
-- **Type:** `String`
-
-- **Detail:**
-
-  Key in incoming json containing `'rows'` data list.
-
-- **Default:** `'rows'`
-
-## method
-
-- **Attribute:** `data-method`
-
-- **Type:** `String`
-
-- **Detail:**
-
-  The method type to request remote data.
-
-- **Default:** `'get'`
+- **Example:** [From Data](https://examples.bootstrap-table.com/#options/from-data.html)
 
 
 ## url
 ## url
 
 
@@ -333,17 +304,21 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `undefined`
 - **Default:** `undefined`
 
 
-## ajax
+- **Example:** [From URL](https://examples.bootstrap-table.com/#options/from-url.html)
 
 
-- **Attribute:** `data-ajax`
+## method
 
 
-- **Type:** `Function`
+- **Attribute:** `data-method`
+
+- **Type:** `String`
 
 
 - **Detail:**
 - **Detail:**
 
 
-  A method to replace ajax call. Should implement the same API as jQuery ajax method.
+  The method type to request remote data.
 
 
-- **Default:** `undefined`
+- **Default:** `'get'`
+
+- **Example:** [Table Method](https://examples.bootstrap-table.com/#options/table-method.html)
 
 
 ## cache
 ## cache
 
 
@@ -357,6 +332,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `true`
 - **Default:** `true`
 
 
+- **Example:** [Table Cache](https://examples.bootstrap-table.com/#options/table-cache.html)
+
 ## contentType
 ## contentType
 
 
 - **Attribute:** `data-content-type`
 - **Attribute:** `data-content-type`
@@ -365,10 +342,12 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Detail:**
 - **Detail:**
 
 
-  The contentType of request remote data.
+  The contentType of request remote data, for example: `application/x-www-form-urlencoded`.
 
 
 - **Default:** `'application/json'`
 - **Default:** `'application/json'`
 
 
+- **Example:** [Content Type](https://examples.bootstrap-table.com/#options/content-type.html)
+
 ## dataType
 ## dataType
 
 
 - **Attribute:** `data-data-type`
 - **Attribute:** `data-data-type`
@@ -381,6 +360,22 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `'json'`
 - **Default:** `'json'`
 
 
+- **Example:** [Data Type](https://examples.bootstrap-table.com/#options/data-type.html)
+
+## ajax
+
+- **Attribute:** `data-ajax`
+
+- **Type:** `Function`
+
+- **Detail:**
+
+  A method to replace ajax call. Should implement the same API as jQuery ajax method.
+
+- **Default:** `undefined`
+
+- **Example:** [Table AJAX](https://examples.bootstrap-table.com/#options/table-ajax.html)
+
 ## ajaxOptions
 ## ajaxOptions
 
 
 - **Attribute:** `data-ajax-options`
 - **Attribute:** `data-ajax-options`
@@ -393,6 +388,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `{}`
 - **Default:** `{}`
 
 
+- **Example:** [AJAX Options](https://examples.bootstrap-table.com/#options/ajax-options.html)
+
 ## queryParams
 ## queryParams
 
 
 - **Attribute:** `data-query-params`
 - **Attribute:** `data-query-params`
@@ -437,6 +434,30 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Default:** `function(res) { return res }`
 - **Default:** `function(res) { return res }`
 
 
+## totalField
+
+- **Attribute:** `data-total-field`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  Key in incoming json containing `'total'` data .
+
+- **Default:** `'total'`
+
+## dataField
+
+- **Attribute:** `data-data-field`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  Key in incoming json containing `'rows'` data list.
+
+- **Default:** `'rows'`
+
 ## pagination
 ## pagination
 
 
 - **Attribute:** `data-pagination`
 - **Attribute:** `data-pagination`
@@ -740,7 +761,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
   }
   }
   {% endhighlight %}
   {% endhighlight %}
 
 
-- **Default:** `$.noop`
+- **Default:** `undefined`
 
 
 ## showHeader
 ## showHeader