Browse Source

Merge pull request #105 from wenzhixin/develop

Update branch
Dennis Hernández 9 years ago
parent
commit
f2eedaa727

+ 118 - 96
CHANGELOG.md

@@ -1,4 +1,26 @@
-## ChangeLog
+ChangeLog
+---------
+
+### 1.10.2
+
+- fix(js): fix cardVisible doesn't work bug
+- feat(js): add support for transfer from rowspan / colspan table
+- fix(js): int field break toggleColumn
+- fix(locale): update it-IT locale
+- fix(locale): add formatAllRows in template locale
+- fix(js): table elements inside bootstrap table bug
+- docs(filter-control extension): add documentation for filterData
+- feat(js): add data variable to post-body event
+- feat(js): add `buttonsClass` option
+- fix(js): move formatter after cellStyle
+- feat(js): add `getVisibleColumns` method
+- feat(js): add resize event to fit the header
+- fix(js): the footer is hidden in card view
+- fix(filter-control extension): add check for null values on existsOptionInSelectControl
+- fix(js): fix sorting rows not working bug
+- refactor(filter-control extension): refactor the filterDataType method
+- feat(angular extension): add constant in order to get it from angular scope
+- fix(js): return field from visible cells
 
 ### 1.10.1
 
@@ -219,149 +241,149 @@
 
 ### 1.2.4
 
-* [enh] Fix #23: Add css and classes parameters to column cell.
-* [enh] Fix #64: Add support for change remote url.
-* [enh] Fix #112: update the `refresh` method.
-* [bug] Fix #113: Using radio type and cardView error.
-* [enh] Fix #117: Add `updateRow` method.
-* [enh] Fix #96, #103: apply `class` option to td elements.
-* [enh] Fix #97: add `sortable` class to header cells instead of `cursor: pointer`.
-* [enh] Fix #124: change `queryParams` and `queryParamsType` default option.
-* [enh] Remove the `eval` method.
-* [enh] Add `bootstrap-table-it-IT.js` locale.
+- [enh] Fix #23: Add css and classes parameters to column cell.
+- [enh] Fix #64: Add support for change remote url.
+- [enh] Fix #112: update the `refresh` method.
+- [bug] Fix #113: Using radio type and cardView error.
+- [enh] Fix #117: Add `updateRow` method.
+- [enh] Fix #96, #103: apply `class` option to td elements.
+- [enh] Fix #97: add `sortable` class to header cells instead of `cursor: pointer`.
+- [enh] Fix #124: change `queryParams` and `queryParamsType` default option.
+- [enh] Remove the `eval` method.
+- [enh] Add `bootstrap-table-it-IT.js` locale.
 
 ### 1.2.3
 
-* [bug] Fix the selected row class reset after toggle column bug.
-* [bug] Fix #86: invisible column are still searchable.
-* [bug] Fix search result error when toggle column display.
-* [enh] Add `clickToSelect` to columns.
-* [bug] Fix click-row event bug.
-* [enh] When field is undefined, use index instead.
-* [enh] Add `cache` option for AJAX calls.
-* [enh] Improve zh-TW translation.
-* [enh] #82: Add `getData` method.
-* [enh] #82: Add `remove` method.
+- [bug] Fix the selected row class reset after toggle column bug.
+- [bug] Fix #86: invisible column are still searchable.
+- [bug] Fix search result error when toggle column display.
+- [enh] Add `clickToSelect` to columns.
+- [bug] Fix click-row event bug.
+- [enh] When field is undefined, use index instead.
+- [enh] Add `cache` option for AJAX calls.
+- [enh] Improve zh-TW translation.
+- [enh] #82: Add `getData` method.
+- [enh] #82: Add `remove` method.
 
 ### 1.2.2
 
-* Fix #68: Add `showColumn`/`hideColumn` methods.
-* Fix #69: Add `bootstrap-table-es_AR.js` locale.
-* Fix #88: Add `bootstrap-table-fr_BE.js` locale.
-* Fix #85: Select row and add row class.
-* Add `halign` column option.
+- Fix #68: Add `showColumn`/`hideColumn` methods.
+- Fix #69: Add `bootstrap-table-es_AR.js` locale.
+- Fix #88: Add `bootstrap-table-fr_BE.js` locale.
+- Fix #85: Select row and add row class.
+- Add `halign` column option.
 
 ### 1.2.1
 
-* Fix #56: Pagination issue in bootstrap 2.3.
-* Fix #76: After refreshing table data, search no longer works.
-* Fix #77: After searching and then clearing the search field, table is no longer sortable.
-* Add `sortable` option, `false` to disable sortable of all columns.
-* Support localization for docs.
+- Fix #56: Pagination issue in bootstrap 2.3.
+- Fix #76: After refreshing table data, search no longer works.
+- Fix #77: After searching and then clearing the search field, table is no longer sortable.
+- Add `sortable` option, `false` to disable sortable of all columns.
+- Support localization for docs.
 
 ### 1.2.0
 
-* Fix bootstrap 2 table border bug.
-* Fix loading and not found record display bug.
-* Update ```minimunCountColumns``` option to ```minimumCountColumns```.
-* Fix sort order bug.
+- Fix bootstrap 2 table border bug.
+- Fix loading and not found record display bug.
+- Update `minimunCountColumns` option to `minimumCountColumns`.
+- Fix sort order bug.
 
 ### 1.1.5
 
-* Fix the bottom border bug on Chrome.
-* Add horizontal scroll for support.
-* Fix scroll header width error.
-* Add ```showRefresh``` and ```showToggle``` options.
+- Fix the bottom border bug on Chrome.
+- Add horizontal scroll for support.
+- Fix scroll header width error.
+- Add `showRefresh` and `showToggle` options.
 
 ### 1.1.4
 
-* Fix ```destroy``` method bug.
-* Initialize table data from HTML.
-* Fix the hidden table reset header bug.
+- Fix `destroy` method bug.
+- Initialize table data from HTML.
+- Fix the hidden table reset header bug.
 
 ### 1.1.3
 
-* Add ```events``` column option.
-* Add ```checkboxHeader``` option.
-* Add ```queryParamsType``` option.
-* Fix ie class bug, and fix duplicated data error.
+- Add `events` column option.
+- Add `checkboxHeader` option.
+- Add `queryParamsType` option.
+- Fix ie class bug, and fix duplicated data error.
 
 ### 1.1.2
 
-* Add switchable column option.
-* Add ```data-toggle``` attribute.
-* Add support for number search.
-* Use html function instead of text in header th.
+- Add switchable column option.
+- Add `data-toggle` attribute.
+- Add support for number search.
+- Use html function instead of text in header th.
 
 ### 1.1.1
 
-* Remove ```bootstrapVerion``` option.
-* Add ```data-page-list``` attribute.
-* Fix search data error.
-* Non case sensitive search in client side.
-* Added support for Danish translation.
+- Remove `bootstrapVerion` option.
+- Add `data-page-list` attribute.
+- Fix search data error.
+- Non case sensitive search in client side.
+- Added support for Danish translation.
 
 ### 1.1.0
 
-* Fix old firefox browser display error.
-* Add minimunCountColumns option.
-* Update the table body header implementation and resetView method.
-* Remove bootstrapVersion option.
-* Fix search data error.
+- Fix old firefox browser display error.
+- Add minimunCountColumns option.
+- Update the table body header implementation and resetView method.
+- Remove bootstrapVersion option.
+- Fix search data error.
 
 ### 1.0.6
 
-* Add jQuery events.
-* Add ```onDblClickRow``` event and ```onAll``` event.
-* Add ```singleSelect``` option.
-* Search improvent: add a timeout and trigger the search event when the text has changed to improve the search.
-* Scroll to top after data loaded.
-* Add ```toolbar``` option.
-* Add ```rowStyle``` option.
-* Add ```bootstrapVersion``` option.
+- Add jQuery events.
+- Add `onDblClickRow` event and `onAll` event.
+- Add `singleSelect` option.
+- Search improvent: add a timeout and trigger the search event when the text has changed to improve the search.
+- Scroll to top after data loaded.
+- Add `toolbar` option.
+- Add `rowStyle` option.
+- Add `bootstrapVersion` option.
 
 ### 1.0.5
 
-* Update the pagination list position.
-* Update ```queryParams``` option.
-* Add ```contentType``` and ```onBeforeLoad``` options.
-* Add server side pagination(```pageSize, pageNumber, searchText, sortName, sortOrder```).
-* Add ```COLUMN_DEFAULTS```.
-* Add ```refresh``` method.
-* Add ```index``` argument in ```formatter``` function.
-* Update card view display.
+- Update the pagination list position.
+- Update `queryParams` option.
+- Add `contentType` and `onBeforeLoad` options.
+- Add server side pagination(`pageSize, pageNumber, searchText, sortName, sortOrder`).
+- Add `COLUMN_DEFAULTS`.
+- Add `refresh` method.
+- Add `index` argument in `formatter` function.
+- Update card view display.
 
 ### 1.0.4
 
-* Add ```showLoading``` and ```hideLoading``` methods.
-* Add ```onLoadSuccess``` and ```onLoadError``` events.
-* Add ```clickToSelect``` option.
-* Add ```cardView``` option.
-* Add loading with ```formatLoadingMessage``` function.
-* Add ```idField``` option.
+- Add `showLoading` and `hideLoading` methods.
+- Add `onLoadSuccess` and `onLoadError` events.
+- Add `clickToSelect` option.
+- Add `cardView` option.
+- Add loading with `formatLoadingMessage` function.
+- Add `idField` option.
 
 ### 1.0.3
 
-* Update fixed headers.
-* Add zh-TW locale file.
-* Add ```showColumns``` option and ```visible``` column option.
-* Update ```hideHeader``` option to ```showHeader```.
-* Add ```formatNoMatches``` locale function.
-* Add table events.
+- Update fixed headers.
+- Add zh-TW locale file.
+- Add `showColumns` option and `visible` column option.
+- Update `hideHeader` option to `showHeader`.
+- Add `formatNoMatches` locale function.
+- Add table events.
 
 ### 1.0.2
 
-* Add i18n support.
-* Add ```selectItemName``` option.
-* Update the ```pageList``` default.
-* Add ```search``` option.
-* Add ```destroy``` method.
-* Add page list support.
+- Add i18n support.
+- Add `selectItemName` option.
+- Update the `pageList` default.
+- Add `search` option.
+- Add `destroy` method.
+- Add page list support.
 
 ### 1.0.1
 
-* Add ```pagination``` support.
+- Add `pagination` support.
 
 ### 1.0.0
 
-* Initial release
+- Initial release

+ 6 - 1
DONATORS.md

@@ -21,7 +21,9 @@
 * 우공이산 우공이산 - $50
 * Empirica srl - $15
 * Hassan Gareballa - $10
-* Jihwang Yi - $10
+* 지황 이 - $10
+* Onur Kose - $15
+* Александр Вейсов - $30
 
 ## 支付宝
 
@@ -39,3 +41,6 @@
 
 * 笑:50元
 * 一牛九毛:100元
+* 111111:4元
+* 佚名:6.6元
+* Evo4me:30元

+ 17 - 0
docs/data/extensions.json

@@ -85,6 +85,23 @@
         }
     },
     {
+      "name": "Copy Rows",
+      "version": "1.0.0",
+      "description": "Allows pushing of selected column data to the clipboard.",
+      "url": "https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/copy-rows",
+      "example": "http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/copy-rows.html",
+
+      "plugins": [{
+        "name": "copy-rows",
+        "url": "https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/copy-rows"
+        }],
+
+        "author": {
+            "name": "Homer Glascock",
+            "image": "https://avatars1.githubusercontent.com/u/5546710"
+        }
+    },
+    {
         "name": "Filter Control",
         "version": "1.0.0",
         "description": "Plugin to add input/select element on the top of the columns in order to filter the data.",

+ 15 - 13
src/bootstrap-table.js

@@ -4,7 +4,7 @@
  * https://github.com/wenzhixin/bootstrap-table/
  */
 
-!function ($) {
+(function ($) {
     'use strict';
 
     // TOOLS DEFINITION
@@ -475,7 +475,7 @@
 
     BootstrapTable.LOCALES = [];
 
-    BootstrapTable.LOCALES['en-US'] = BootstrapTable.LOCALES['en'] = {
+    BootstrapTable.LOCALES['en-US'] = BootstrapTable.LOCALES.en = {
         formatLoadingMessage: function () {
             return 'Loading, please wait...';
         },
@@ -589,7 +589,7 @@
         if (this.options.locale) {
             var parts = this.options.locale.split(/-|_/);
             parts[0].toLowerCase();
-            parts[1] && parts[1].toUpperCase();
+            if (parts[1]) parts[1].toUpperCase();
             if ($.fn.bootstrapTable.locales[this.options.locale]) {
                 // locale as requested
                 $.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale]);
@@ -661,7 +661,7 @@
             $(this).find('th').each(function () {
                 // Fix #2014 - getFieldIndex and elsewhere assume this is string, causes issues if not
                 if (typeof $(this).data('field') !== 'undefined') {
-                    $(this).data('field', new String($(this).data('field')).valueOf()); 
+                    $(this).data('field', $(this).data('field') + '');
                 }
                 column.push($.extend({}, {
                     title: $(this).html(),
@@ -760,7 +760,7 @@
         $.each(this.options.columns, function (i, columns) {
             html.push('<tr>');
 
-            if (i == 0 && !that.options.cardView && that.options.detailView) {
+            if (i === 0 && !that.options.cardView && that.options.detailView) {
                 html.push(sprintf('<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>',
                     that.options.columns.length));
             }
@@ -1290,7 +1290,8 @@
             $first, $pre,
             $next, $last,
             $number,
-            data = this.getData();
+            data = this.getData(),
+            pageList = this.options.pageList;
 
         if (this.options.sidePagination !== 'server') {
             this.options.totalRows = data.length;
@@ -1350,8 +1351,7 @@
                     ' <span class="caret"></span>',
                     '</button>',
                     '<ul class="dropdown-menu" role="menu">'
-                ],
-                pageList = this.options.pageList;
+                ];
 
             if (typeof this.options.pageList === 'string') {
                 var list = this.options.pageList.replace('[', '').replace(']', '')
@@ -1536,7 +1536,7 @@
     };
 
     BootstrapTable.prototype.onPagePre = function (event) {
-        if ((this.options.pageNumber - 1) == 0) {
+        if ((this.options.pageNumber - 1) === 0) {
             this.options.pageNumber = this.options.totalPages;
         } else {
             this.options.pageNumber--;
@@ -1939,7 +1939,7 @@
         }
 
         if (!($.isEmptyObject(this.filterColumnsPartial))) {
-            params['filter'] = JSON.stringify(this.filterColumnsPartial, null);
+            params.filter = JSON.stringify(this.filterColumnsPartial, null);
         }
 
         data = calculateObjectValue(this.options, this.options.queryParams, [params], data);
@@ -2460,9 +2460,10 @@
             if (rowId === -1) {
                 return;
             }
-            $.extend(that.data[rowId], params.row);
+            $.extend(that.options.data[rowId], params.row);
         });
 
+        this.initSearch();
         this.initSort();
         this.initBody(true);
     };
@@ -2486,9 +2487,10 @@
             if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
                 return;
             }
-            $.extend(that.data[params.index], params.row);
+            $.extend(that.options.data[params.index], params.row);
         });
 
+        this.initSearch();
         this.initSort();
         this.initBody(true);
     };
@@ -2992,4 +2994,4 @@
     $(function () {
         $('[data-toggle="table"]').bootstrapTable();
     });
-}(jQuery);
+})(jQuery);

+ 41 - 0
src/extensions/copy-rows/README.md

@@ -0,0 +1,41 @@
+# Copy Rows
+
+Use Plugin: [copy-rows](https://github.com/wenzhixin/bootstrap-table/tree/develop/src/extensions/copy-rows)
+
+This extension adds functionality for copying selected rows to the clipboard. Currently works on all desktop browsers except safari.
+
+## Usage
+
+```html
+<script src="extensions/copy-rows/bootstrap-table-copy-rows.js"></script>
+```
+
+## Options
+
+### copyBtn
+
+* type: Boolean
+* description: Set true to show the copy button. This button copys the contents of the selected rows to the clipboard.
+* default: `false`
+
+### copyWHiddenBtn
+
+* type: Boolean
+* description: Set true to show the copy with hidden button. This button copys the contents of the selected rows to the clipboard, *including hidden rows*.
+* default: `false`
+
+### copyDelemeter
+
+* type: String
+* description: This string will be inserted in-between the column values when copying
+* default: ` `
+
+## Methods
+
+### copyColumnsToClipboard
+
+* copys the contents of the selected rows to the clipboard.
+
+### copyColumnsToClipboardWithHidden
+
+* copys the contents of the selected rows to the clipboard, *including hidden rows*.

+ 102 - 0
src/extensions/copy-rows/bootstrap-table-copy-rows.js

@@ -0,0 +1,102 @@
+/**
+ * @author Homer Glascock <HopGlascock@gmail.com>
+ * @version: v1.0.0
+ */
+
+ !function ($) {
+    "use strict";
+
+    var calculateObjectValue = $.fn.bootstrapTable.utils.calculateObjectValue,
+        sprintf = $.fn.bootstrapTable.utils.sprintf;
+
+    var copytext = function (text) {
+        var textField = document.createElement('textarea');
+        $(textField).html(text);
+        document.body.appendChild(textField);
+        textField.select();
+
+        try {
+            document.execCommand('copy');
+        }
+        catch (e) {
+            console.log("Oops, unable to copy");
+        }
+        $(textField).remove();
+    };
+
+    $.extend($.fn.bootstrapTable.defaults, {
+        copyBtn: false,
+        copyWHiddenBtn: false,
+        copyDelemeter: ", "
+    });
+
+    $.fn.bootstrapTable.methods.push('copyColumnsToClipboard', 'copyColumnsToClipboardWithHidden');
+
+    var BootstrapTable = $.fn.bootstrapTable.Constructor,
+        _initToolbar = BootstrapTable.prototype.initToolbar;
+
+    BootstrapTable.prototype.initToolbar = function () {
+
+        _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
+
+        var that = this,
+            $btnGroup = this.$toolbar.find('>.btn-group');
+
+        if (this.options.clickToSelect || this.options.singleSelect) {
+
+            if (this.options.copyBtn) {
+                var copybtn = "<button class='btn btn-default' id='copyBtn'><span class='glyphicon glyphicon-copy icon-pencil'></span></button>";
+                $btnGroup.append(copybtn);
+                $btnGroup.find('#copyBtn').click(function () { that.copyColumnsToClipboard(); });
+            }
+
+            if (this.options.copyWHiddenBtn) {
+                var copyhiddenbtn = "<button class='btn btn-default' id='copyWHiddenBtn'><span class='badge'><span class='glyphicon glyphicon-copy icon-pencil'></span></span></button>";
+                $btnGroup.append(copyhiddenbtn);
+                $btnGroup.find('#copyWHiddenBtn').click(function () { that.copyColumnsToClipboardWithHidden(); });
+            }
+        }
+    };
+
+    BootstrapTable.prototype.copyColumnsToClipboard = function () {
+        var that = this,
+            ret = "",
+            delimet = this.options.copyDelemeter;
+
+        $.each(that.getSelections(), function (index, row) {
+            $.each(that.options.columns[0], function (indy, column) {
+                if (column.field !== "state" && column.field !== "RowNumber" && column.visible) {
+                    if (row[column.field] !== null) {
+                        ret += calculateObjectValue(column, that.header.formatters[indy], [row[column.field], row, index], row[column.field]);
+                    }
+                    ret += delimet;
+                }
+            });
+
+            ret += "\r\n";
+        });
+
+        copytext(ret);
+    };
+
+    BootstrapTable.prototype.copyColumnsToClipboardWithHidden = function () {
+        var that = this,
+            ret = "",
+            delimet = this.options.copyDelemeter;
+
+        $.each(that.getSelections(), function (index, row) {
+            $.each(that.options.columns[0], function (indy, column) {
+                if (column.field != "state" && column.field !== "RowNumber") {
+                    if (row[column.field] !== null) {
+                        ret += calculateObjectValue(column, that.header.formatters[indy], [row[column.field], row, index], row[column.field]);
+                    }
+                    ret += delimet;
+                }
+            });
+
+            ret += "\r\n";
+        });
+
+        copytext(ret);
+    };
+}(jQuery);

+ 17 - 0
src/extensions/copy-rows/extension.json

@@ -0,0 +1,17 @@
+{
+  "name": "Copy Rows",
+  "version": "1.0.0",
+  "description": "Allows pushing of selected column data to the clipboard.",
+  "url": "https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/copy-rows",
+  "example": "http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/copy-rows.html",
+
+  "plugins": [{
+    "name": "copy-rows",
+    "url": "https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/copy-rows"
+  }],
+
+  "author": {
+    "name": "Homer Glascock",
+    "image": "https://avatars1.githubusercontent.com/u/5546710"
+  }
+}

+ 6 - 1
src/extensions/filter-control/README.md

@@ -40,7 +40,7 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
 ### filterData
 
 * type: String
-* description: Set custom select filter values, use `var:variable` to load from a variable or `url:http://www.example.com/data.json` to load from json file. 
+* description: Set custom select filter values, use `var:variable` to load from a variable or `url:http://www.example.com/data.json` to load from a remote json file or `jso:{key:data}` to load from a json string. 
 * default: `undefined`
 
 ### filterDatepickerOptions
@@ -53,6 +53,11 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
 * description: Set to true if you want to use the strict search mode.
 * default: `false`
 
+### filterStartsWithSearch
+* type: Boolean
+* description: Set to true if you want to use the starts with search mode.
+* default: `false`
+
 ### Icons
 * clear: 'glyphicon-trash icon-clear'
 

+ 53 - 18
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -4,7 +4,7 @@
  * @version: v2.1.0
  */
 
-!function ($) {
+(function ($) {
 
     'use strict';
 
@@ -175,17 +175,14 @@
                 return selectControl && selectControl.length > 0;
             };
 
-        var z = that.options.pagination
-                ? (that.options.sidePagination === 'server'
-                    ? that.pageTo
-                    : that.options.totalRows)
-                : that.pageTo;
+        var z = that.options.pagination ?
+            (that.options.sidePagination === 'server' ? that.pageTo : that.options.totalRows) :
+            that.pageTo;
 
         for (var i = 0; i < z; i++) {
             $.each(that.header.fields, function (j, field) {
                 var column = that.columns[$.fn.bootstrapTable.utils.getFieldIndex(that.columns, field)],
-                    selectControl = $('.' + column.field);
-
+                    selectControl = $('.' + escapeID(column.field));
 
                 if (isColumnSearchableViaSelect(column) && isFilterDataNotGiven(column) && hasSelectControlElement(selectControl)) {
                     if (selectControl.get(selectControl.length - 1).options.length === 0) {
@@ -204,6 +201,10 @@
 
     };
 
+    var escapeID = function( id ) {
+       return String(id).replace( /(:|\.|\[|\]|,)/g, "\\$1" );
+   };
+
     var createControls = function (that, header) {
         var addedFilterControl = false,
             isVisible,
@@ -241,16 +242,44 @@
 
             if (column.filterData !== undefined && column.filterData.toLowerCase() !== 'column') {
                 var filterDataType = getFilterDataMethod(filterDataMethods, column.filterData.substring(0, column.filterData.indexOf(':')));
+                var filterDataSource, selectControl;
 
                 if (filterDataType !== null) {
-                    var filterDataSource = column.filterData.substring(column.filterData.indexOf(':') + 1, column.filterData.length),
-                        selectControl = $('.' + column.field);
+                    filterDataSource = column.filterData.substring(column.filterData.indexOf(':') + 1, column.filterData.length);
+                    selectControl = $('.' + escapeID(column.field));
 
                     addOptionToSelectControl(selectControl, '', '');
                     filterDataType(filterDataSource, selectControl);
                 } else {
                     throw new SyntaxError('Error. You should use any of these allowed filter data methods: var, json, url.' + ' Use like this: var: {key: "value"}');
                 }
+
+                var variableValues, key;
+                switch (filterDataType) {
+                    case 'url':
+                        $.ajax({
+                            url: filterDataSource,
+                            dataType: 'json',
+                            success: function (data) {
+                                $.each(data, function (key, value) {
+                                    addOptionToSelectControl(selectControl, key, value);
+                                });
+                            }
+                        });
+                        break;
+                    case 'var':
+                        variableValues = window[filterDataSource];
+                        for (key in variableValues) {
+                            addOptionToSelectControl(selectControl, key, variableValues[key]);
+                        }
+                        break;
+                    case 'jso':
+                        variableValues = JSON.parse(filterDataSource);
+                        for (key in variableValues) {
+                            addOptionToSelectControl(selectControl, key, variableValues[key]);
+                        }
+                        break;
+                }
             }
         });
 
@@ -316,7 +345,7 @@
             case 'auto':
                 return 'auto';
             default:
-                return 'ltr'
+                return 'ltr';
         }
     };
 
@@ -370,7 +399,7 @@
             },
             select: function (that, field, isVisible) {
                 return sprintf('<select class="%s form-control" style="width: 100%; visibility: %s" dir="%s"></select>',
-                    field, isVisible, getDirectionOfSelectOptions(that.options.alignmentSelectControlOptions))
+                    field, isVisible, getDirectionOfSelectOptions(that.options.alignmentSelectControlOptions));
             },
             datepicker: function (that, field, isVisible) {
                 return sprintf('<input type="text" class="date-filter-control %s form-control" style="width: 100%; visibility: %s">', field, isVisible);
@@ -384,7 +413,8 @@
         filterControl: undefined,
         filterData: undefined,
         filterDatepickerOptions: undefined,
-        filterStrictSearch: false
+        filterStrictSearch: false,
+        filterStartsWithSearch: false
     });
 
     $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
@@ -489,7 +519,7 @@
     BootstrapTable.prototype.initSearch = function () {
         _initSearch.apply(this, Array.prototype.slice.apply(arguments));
 
-        if (!this.options.sidePagination === 'server') {
+        if (this.options.sidePagination !== 'server') {
             return;
         }
 
@@ -502,7 +532,7 @@
                 var thisColumn = that.columns[$.fn.bootstrapTable.utils.getFieldIndex(that.columns, key)];
                 var fval = fp[key].toLowerCase();
                 var value = item[key];
-                
+
                 // Fix #142: search use formated data
                 if (thisColumn && thisColumn.searchFormatter) {
                     value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
@@ -516,8 +546,13 @@
                         value.toString().toLowerCase() === fval.toString().toLowerCase())) {
                         return false;
                     }
-                }
-                else {
+                } else if (thisColumn.filterStartsWithSearch) {
+                  if (!($.inArray(key, that.header.fields) !== -1 &&
+                      (typeof value === 'string' || typeof value === 'number') &&
+                      (value + '').toLowerCase().indexOf(fval) === 0)) {
+                      return false;
+                  }
+                } else {
                     if (!($.inArray(key, that.header.fields) !== -1 &&
                         (typeof value === 'string' || typeof value === 'number') &&
                         (value + '').toLowerCase().indexOf(fval) !== -1)) {
@@ -599,4 +634,4 @@
             }, that.options.searchTimeOut);
         }
     };
-}(jQuery);
+})(jQuery);

+ 18 - 3
src/locale/bootstrap-table-pt-PT.js

@@ -7,19 +7,34 @@
 
     $.fn.bootstrapTable.locales['pt-PT'] = {
         formatLoadingMessage: function () {
-            return 'A carregar, aguarde...';
+            return 'A carregar, por favor aguarde...';
         },
         formatRecordsPerPage: function (pageNumber) {
-            return pageNumber + ' registos por página';
+            return pageNumber + ' registos por p&aacute;gina';
         },
         formatShowingRows: function (pageFrom, pageTo, totalRows) {
-            return 'A mostrar ' + pageFrom + ' até ' + pageTo + ' de ' + totalRows + ' linhas';
+            return 'A mostrar ' + pageFrom + ' at&eacute; ' + pageTo + ' de ' + totalRows + ' linhas';
         },
         formatSearch: function () {
             return 'Pesquisa';
         },
         formatNoMatches: function () {
             return 'Nenhum registo encontrado';
+        },
+        formatPaginationSwitch: function () {
+            return 'Esconder/Mostrar pagina&ccedil&atilde;o';
+        },
+        formatRefresh: function () {
+            return 'Atualizar';
+        },
+        formatToggle: function () {
+            return 'Alternar';
+        },
+        formatColumns: function () {
+            return 'Colunas';
+        },
+        formatAllRows: function () {
+            return 'Tudo';
         }
     };