Browse Source

Merge pull request #6700 from cwh42/fix_filter_control_nested_attributes

Fix inputs losing their content when using nested attributes
文翼 2 years ago
parent
commit
fcb82f032e
2 changed files with 8 additions and 4 deletions
  1. 4 0
      CHANGELOG.md
  2. 4 4
      src/extensions/filter-control/utils.js

+ 4 - 0
CHANGELOG.md

@@ -8,6 +8,10 @@ ChangeLog
 - **Update:** Fixed Maximum call stack size exceeded error.
 - **Update:** Fixed getData bug with hidden rows.
 
+#### Extensions
+
+- **Update(filter-control):** Fixed inputs losing their content when using nested attributes.
+
 ### 1.21.3
 
 #### Core

+ 4 - 4
src/extensions/filter-control/utils.js

@@ -146,7 +146,7 @@ export function cacheValues (that) {
 
   searchControls.each(function () {
     let $field = $(this)
-    const fieldClass = getElementClass($field)
+    const fieldClass = escapeID(getElementClass($field))
 
     if (that.options.height && !that.options.filterControlContainer) {
       $field = that.$el.find(`.fixed-table-header .${fieldClass}`)
@@ -360,7 +360,7 @@ export function createControls (that, header) {
 
     if (
       !column.visible &&
-      !(that.options.filterControlContainer && $(`.bootstrap-table-filter-control-${column.field}`).length >= 1)
+      !(that.options.filterControlContainer && $(`.bootstrap-table-filter-control-${escapeID(column.field)}`).length >= 1)
     ) {
       return
     }
@@ -369,7 +369,7 @@ export function createControls (that, header) {
       html.push('<div class="no-filter-control"></div>')
     } else if (that.options.filterControlContainer) {
       // Use a filter control container instead of th
-      const $filterControls = $(`.bootstrap-table-filter-control-${column.field}`)
+      const $filterControls = $(`.bootstrap-table-filter-control-${escapeID(column.field)}`)
 
       $.each($filterControls, (_, filterControl) => {
         const $filterControl = $(filterControl)
@@ -523,7 +523,7 @@ export function createControls (that, header) {
     if (header.find('.date-filter-control').length > 0) {
       $.each(that.columns, (i, { filterDefault, filterControl, field, filterDatepickerOptions }) => {
         if (filterControl !== undefined && filterControl.toLowerCase() === 'datepicker') {
-          const $datepicker = header.find(`.date-filter-control.bootstrap-table-filter-control-${field}`)
+          const $datepicker = header.find(`.date-filter-control.bootstrap-table-filter-control-${escapeID(field)}`)
 
           if (filterDefault) {
             $datepicker.value(filterDefault)