|
170 | 170 | var parsedCookieFilters = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl)); |
171 | 171 |
|
172 | 172 | if (!bootstrapTable.options.filterControlValuesLoaded && parsedCookieFilters) { |
173 | | - bootstrapTable.options.filterControlValuesLoaded = true; |
174 | 173 |
|
175 | 174 | var cachedFilters = {}, |
176 | 175 | header = getCurrentHeader(bootstrapTable), |
|
193 | 192 | }); |
194 | 193 |
|
195 | 194 | bootstrapTable.initColumnSearch(cachedFilters); |
196 | | - bootstrapTable.refresh(); |
| 195 | + bootstrapTable.options.filterControlValuesLoaded = true; |
| 196 | + bootstrapTable.initServer(); |
197 | 197 | } |
198 | 198 | }, 250); |
199 | 199 | }; |
|
241 | 241 | _onSearch = BootstrapTable.prototype.onSearch; |
242 | 242 |
|
243 | 243 | BootstrapTable.prototype.init = function () { |
244 | | - var timeoutId = 0; |
245 | 244 | this.options.filterControls = []; |
246 | 245 | this.options.filterControlValuesLoaded = false; |
247 | 246 |
|
|
276 | 275 | }; |
277 | 276 |
|
278 | 277 | BootstrapTable.prototype.initServer = function () { |
279 | | - var bootstrapTable = this, |
280 | | - selectsWithoutDefaults = [], |
281 | | - |
282 | | - columnHasSelectControl = function (column) { |
283 | | - return column.filterControl && column.filterControl === 'select'; |
284 | | - }, |
285 | | - |
286 | | - columnHasDefaultSelectValues = function (column) { |
287 | | - return column.filterData && column.filterData !== 'column'; |
288 | | - }, |
289 | | - |
290 | | - cookiesPresent = function() { |
291 | | - var cookie = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl)); |
292 | | - return bootstrapTable.options.cookie && cookie; |
293 | | - }; |
294 | | - |
295 | | - selectsWithoutDefaults = $.grep(bootstrapTable.columns, function(column) { |
296 | | - return columnHasSelectControl(column) && !columnHasDefaultSelectValues(column); |
297 | | - }); |
298 | | - |
299 | | - // reset variable to original initServer function, so that future calls to initServer |
300 | | - // use the original function from this point on. |
301 | | - BootstrapTable.prototype.initServer = _initServer; |
302 | | - |
303 | | - // early return if we don't need to populate any select values with cookie values |
304 | | - if (this.options.filterControl && cookiesPresent() && selectsWithoutDefaults.length === 0) { |
305 | | - return; |
| 278 | + var bootstrapTable = this; |
| 279 | + if (bootstrapTable.options.cookie && bootstrapTable.options.filterControl && !bootstrapTable.options.filterControlValuesLoaded) { |
| 280 | + var cookie = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl)); |
| 281 | + if (cookie) |
| 282 | + return; |
306 | 283 | } |
307 | | - |
308 | | - // call BootstrapTable.prototype.initServer |
309 | 284 | _initServer.apply(this, Array.prototype.slice.apply(arguments)); |
310 | 285 | }; |
311 | 286 |
|
|