Browse Source

Fix #5: add 'clickToSelect' option.

zhixin 11 years ago
parent
commit
56ce3a7cee
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/bootstrap-table.js

+ 5 - 1
src/bootstrap-table.js

@@ -78,6 +78,7 @@
         showColumns: false,
         idField: undefined,
         cardView: false,
+        clickToSelect: false,
 
         formatLoadingMessage: function() {
             return 'Loading, please wait…';
@@ -602,9 +603,12 @@
 
         this.$body.find('tr').off('click').on('click', function() {
             that.options.onClickRow(that.data[$(this).data('index')]);
+            if (that.options.clickToSelect) {
+                $(this).find(sprintf('[name="%s"]', that.options.selectItemName)).trigger('click');
+            }
         });
 
-        this.$selectItem = this.$body.find('[name="btSelectItem"]');
+        this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName));
         this.$selectItem.off('click').on('click', function(event) {
             event.stopImmediatePropagation();
             var checkAll = that.$selectItem.length === that.$selectItem.filter(':checked').length,