The value entered in the global search field is overwritten by the value entered in the column search field
See original GitHub issueBootstraptable version(s) affected
1.18.3
Description
There is a table with the following parameters:
data-cookie="true"
data-cookie-id-table="tblItemsObjLvl"
data-locale="sv-SE"
data-toggle="table"
data-show-export="true"
data-export-options='{"fileName": "BuildID_objektlista"}'
data-export-types="['json', 'csv', 'excel']"
data-pagination="true"
data-page-size="25"
data-side-pagination="server"
data-click-to-select="true"
data-buttons-class="success"
data-buttons-toolbar=".buttons-toolbar"
data-toolbar="#toolbar"
data-show-toggle="false"
data-show-columns="true"
data-ajax="ajaxRequest"
data-filter-control="true"
data-show-search-clear-button="true"
data-detail-view="true"
data-search="true"
The table has a columns with data-filter-control
set to select
and input
.
For columns with data-filter-control = select
, a caching variable is set via the data-filter-data
parameter.
The table has global search enabled - data-search="true"
Data is loaded via ajax request.
When entering data into the global search field, the text from the global search field is passed to the ajaxRequest
function (which is specified in the data-ajax
parameter) in the search
field of the input object of the function.
Example:
{
cache: true
contentType: “application/json”
data: {
limit: 25
offset: 0
order: “asc”
search: “123”
sort: “SubSiteName”
}
dataType: “json”
error: ƒ (e)
success: ƒ (e,i,n)
type: “get”
}
Everything is fine
When a value is selected from the dropdown list (data-filter-control = select
) in a column - the same everything is fine.
The selected value is added to the JSON string in the filter
key in the input object of the ajaxRequest
function Example:
{
cache: true
contentType: “application/json”
data: {
filter: “{"ConstructionStatus":"1"}”
limit: 25
offset: 0
order: “asc”
search: “123”
sort: “SubSiteName”
}
dataType: “json”
error: ƒ (e)
success: ƒ (e,i,n)
type: “get”
}
But when I enter a value in the input field in the column (data-filter-control = input
), the value that I enter is added both to the JSON string in the filter
key and in the search
key, overwriting the value that was there (in the search
key,). Example:
{
cache: true
contentType: “application/json”
data: {
filter: “{"ConstructionStatus":"1","supplier_old":"test"}”
limit: 25
offset: 0
order: “asc”
search: “test”
sort: “SubSiteName”
}
dataType: “json”
error: ƒ (e)
success: ƒ (e,i,n)
type: “get”
}
There is also a nuance with caching. The value entered in the global input field is cached into the same variable as the value entered in the search field in the column. They grind one by one.
In my case, this is the tblItemsObjLvl.bs.table.searchText
variable
At the same time, when trying to set a variable for loading data using the data-filter-data
parameter, an error:
bootstrap-table-filter-control.min.js:10 Uncaught TypeError: Cannot read properties of undefined (reading ‘length’) at bootstrap-table-filter-control.min.js:10:23769 at bn (bootstrap-table-filter-control.min.js:10:23844) at Object.<anonymous> (bootstrap-table-filter-control.min.js:10:28335) at Function.each (jquery.min.js:2:3003) at En (bootstrap-table-filter-control.min.js:10:26822) at p.value (bootstrap-table-filter-control.min.js:10:35599) at p.value (bootstrap-table.min.js:10:107140) at p._toggleColumn (bootstrap-table-cookie.js:2367:87) at HTMLInputElement.<anonymous> (bootstrap-table.min.js:10:69092) at HTMLInputElement.dispatch (jquery.min.js:2:43064)
Code example: data-filter-data = "var:input"
Example(s)
No response
Possible Solutions
No response
Additional Context
In project use admin-lte: 3.1.0 Update the table to 1.19.1 version not fixed this problem
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top GitHub Comments
I think this is fixed in the latest version. Can you confirm https://live.bootstrap-table.com/code/djhvscf/11358? @vladimirruzhyn
Seems fixed for me, if it is still not fixed for you @vladimirruzhyn then please let us know how we can reproduce it and we will reopen the issue.