diff --git a/public/assets/js/bootstrap-table-commonsearch.js b/public/assets/js/bootstrap-table-commonsearch.js index 094906db..7a7d02d9 100644 --- a/public/assets/js/bootstrap-table-commonsearch.js +++ b/public/assets/js/bootstrap-table-commonsearch.js @@ -294,7 +294,7 @@ var isAjax = typeof list === 'object' && typeof list.then === 'function'; if (isFunction) { list = list(); - } else if (isAjax) { + } else if (isAjax && vObjCol) { $.when(list).done(function (ret) { // 兼容旧版本在data中返回searchlist if (typeof ret.data.searchlist !== 'undefined') { @@ -306,10 +306,12 @@ $.each(list, function (key, val) { if (typeof val !== 'undefined' && val.constructor === Object) { key = val.id; - val = val[vObjCol.nameKey || 'name']; + vObjCol.nameKey = typeof vObjCol.nameKey === 'undefined' ? 'name' : vObjCol.nameKey + val = val[vObjCol.nameKey]; } else { key = isArray ? val : key; } + vObjCol.defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue optionList.push(sprintf("", key == vObjCol.defaultValue && vObjCol.defaultValue !='' ? 'selected' : '')); }); $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).append(optionList.join('')).trigger("change");