mirror of https://gitee.com/karson/fastadmin.git
修复searchList使用$.getJSON等异步获取数据异常修复searchList使用$.getJSON等异步获取数据异常
封装的combineSearchList 中 $.when(list) 异步执行,无法拼装option,导致直接返回了jq的数组,显示异常 Signed-off-by: 还俗二师兄 <505097558@qq.com>pull/518/head
parent
8ce35cf2d7
commit
20dd8c6ac9
|
|
@ -134,7 +134,7 @@
|
||||||
var createOptionList = function (searchList, vObjCol, that) {
|
var createOptionList = function (searchList, vObjCol, that) {
|
||||||
var optionList = [];
|
var optionList = [];
|
||||||
optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
|
optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
|
||||||
searchList = $.fn.bootstrapTable.utils.combineSearchList(searchList);
|
searchList = $.fn.bootstrapTable.utils.combineSearchList(searchList, vObjCol, that);
|
||||||
$.each(searchList, function (key, value) {
|
$.each(searchList, function (key, value) {
|
||||||
optionList.push(sprintf("<option value='" + Fast.api.escape(key) + "' %s>" + Fast.api.escape(value) + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
|
optionList.push(sprintf("<option value='" + Fast.api.escape(key) + "' %s>" + Fast.api.escape(value) + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
|
||||||
});
|
});
|
||||||
|
|
@ -286,7 +286,7 @@
|
||||||
_initSearch = BootstrapTable.prototype.initSearch;
|
_initSearch = BootstrapTable.prototype.initSearch;
|
||||||
|
|
||||||
// 定义通用searchList处理方法
|
// 定义通用searchList处理方法
|
||||||
$.fn.bootstrapTable.utils.combineSearchList = function (list) {
|
$.fn.bootstrapTable.utils.combineSearchList = function (list, vObjCol, that) {
|
||||||
var searchList = {};
|
var searchList = {};
|
||||||
|
|
||||||
if (typeof list !== 'undefined') {
|
if (typeof list !== 'undefined') {
|
||||||
|
|
@ -302,7 +302,19 @@
|
||||||
} else {
|
} else {
|
||||||
list = ret;
|
list = ret;
|
||||||
}
|
}
|
||||||
|
let optionList = [];
|
||||||
|
$.each(list, function (key, val) {
|
||||||
|
if (typeof val !== 'undefined' && val.constructor === Object) {
|
||||||
|
key = val.id;
|
||||||
|
val = val[vObjCol.nameKey || 'name'];
|
||||||
|
} else {
|
||||||
|
key = isArray ? val : key;
|
||||||
|
}
|
||||||
|
optionList.push(sprintf("<option value='" + Fast.api.escape(key) + "' %s>" + Fast.api.escape(val) + "</option>", key == vObjCol.defaultValue && vObjCol.defaultValue !='' ? 'selected' : ''));
|
||||||
|
});
|
||||||
|
$("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).append(optionList.join('')).trigger("change");
|
||||||
});
|
});
|
||||||
|
list = '';
|
||||||
}
|
}
|
||||||
// 兼容旧版本searchList返回字符串直接渲染自定义搜索栏
|
// 兼容旧版本searchList返回字符串直接渲染自定义搜索栏
|
||||||
if (typeof list === 'string') {
|
if (typeof list === 'string') {
|
||||||
|
|
@ -438,3 +450,16 @@
|
||||||
}) : this.data;
|
}) : this.data;
|
||||||
};
|
};
|
||||||
}(jQuery);
|
}(jQuery);
|
||||||
|
/**
|
||||||
|
* FastAdmin通用搜索
|
||||||
|
*
|
||||||
|
* @author: pppscn <35696959@qq.com>
|
||||||
|
* @update 2017-05-07 <https://gitee.com/pp/fastadmin>
|
||||||
|
*
|
||||||
|
* @author: Karson <karson@fastadmin.net>
|
||||||
|
* @update 2018-04-05 <https://gitee.com/karson/fastadmin>
|
||||||
|
*/
|
||||||
|
… return true;
|
||||||
|
}) : this.data;
|
||||||
|
};
|
||||||
|
}(jQuery);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue