Browse Source

Merge branch 'develop' into feature/multiselect-filtercontrol

Dennis Hernández 4 years ago
parent
commit
517c910455

+ 28 - 1
site/docs/extensions/copy-rows.md

@@ -68,7 +68,34 @@ This extension adds functionality for copying selected rows to the clipboard. Cu
 
 - **Default:** `false`
 
-### Icons
+## Column options
+
+### ignoreCopy
+
+- **Attribute:** `data-ignore-copy`
+
+- **type:** `Boolean`
+
+- **Detail:**
+
+  Set `true` to ignore this column while copying.
+
+- **Default:** `false`
+
+### rawCopy
+
+- **Attribute:** `data-raw-copy`
+
+- **type:** `Boolean`
+
+- **Detail:**
+
+  Set `true` to copy the raw value instead the formatted one.   
+  If no formatter is used, this option has no effect.
+
+- **Default:** `false`
+
+## Icons
 
 - copy: 'fa-copy'
 

+ 4 - 1
src/bootstrap-table.js

@@ -913,7 +913,10 @@ class BootstrapTable {
         return
       }
 
-      if (currentTarget === Utils.getSearchInput(this)[0] || $(currentTarget).hasClass('search-input')) {
+      const $searchInput = Utils.getSearchInput(this)
+      const $currentTarget = currentTarget instanceof jQuery ? currentTarget : $(currentTarget)
+
+      if ($currentTarget.is($searchInput) || $currentTarget.hasClass('search-input')) {
         this.searchText = text
         this.options.searchText = text
       }

+ 10 - 4
src/extensions/copy-rows/bootstrap-table-copy-rows.js

@@ -43,6 +43,11 @@ $.extend($.fn.bootstrapTable.defaults, {
   copyNewline: '\n'
 })
 
+$.extend($.fn.bootstrapTable.columnDefaults, {
+  ignoreCopy: false,
+  rawCopy: false
+})
+
 $.fn.bootstrapTable.methods.push(
   'copyColumnsToClipboard'
 )
@@ -81,12 +86,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
       $.each(this.options.columns[0], (indy, column) => {
         if (
           column.field !== this.header.stateField &&
-          (!this.options.copyWithHidden ||
-          this.options.copyWithHidden && column.visible)
+          (!this.options.copyWithHidden || this.options.copyWithHidden && column.visible) &&
+          !column.ignoreCopy
         ) {
           if (row[column.field] !== null) {
-            cols.push(Utils.calculateObjectValue(column, this.header.formatters[indy],
-              [row[column.field], row, index], row[column.field]))
+            const columnValue = column.rawCopy ? row[column.field] : Utils.calculateObjectValue(column, this.header.formatters[indy], [row[column.field], row, index], row[column.field])
+
+            cols.push(columnValue)
           }
         }
       })