关于bootstraptable使用x-editable控件的select2类型问题

沿途欣赏i 2019-01-15 10:39:03
1.页面所有数据都已打通,行内编辑界面效果如下所示:

select2可以选也可以搜索,但是问题是select2的数据是在第一次加载页面时直接把全部数据给load过来,把数据源放在本地上实现的。

我想实现的是搜索是从服务端去load数据
代码如下,望各位大神指点一二:

var TableInit = function () {
var oTableInit = new Object();
//初始化Table
oTableInit.Init = function () {
$("#checkMedical").bootstrapTable({
url:"${ctx}medicalhistory/backtrackmhistoryinfo",
type:"get",
pagination: true,//分页
striped: true,//是否显示行间隔色
cache: true, //是否使用缓存默认为true
sortable: false, //是否启用排序
sortOrder: 'asc', //排序方式
undefinedText: '',
clickToSelect:true, //单击行选中对应复选框
ajaxOptions:{async:false},
sidePagination: 'server', //分页方式:client客户端分页,server服务的分页
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 5, //每页的记录行数
pageList: [10, 15, 20],//可供选择的每页的行数
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端
paginationPreText: "上一页",
paginationNextText: "下一页",
fixedColumns: false,//固定列
fixedNumber: 4,//固定前两列
queryParams: oTableInit.queryParams,//传递参数(*)
responseHandler:function (res) {
console.log(res)
return res;
},
columns: [
[{
checkbox:true,
align:"center",
valign:"middle"

},{
field: 'Name',
title: '行号',
rowspan:'2',
formatter: function (value, row, index) {
return index+1;
}
},{
field: "BSID00",
title: "ID",
},{
field: "BSMC00",
title: "病史名称",
editable: {
type: 'text',
title: '病史名称',
validate: function (v) {
if (!v) return '病史名称不能为空';
}
}
},{
field: "SFCY00",
title: "常用",
editable: {
type: "select",
separator:",",
source: [{ value: '1', text: '常用' },
{ value: '0', text: '不常用' }],
}
},{
field: "",
title: "病史类别",
},{
field: "ICDBM0",
title: "ICD编码",
editable: {
type: 'select2',
title: 'ICD编码',
name : 'ICDBM0',
source : function () {//动态获取数据
var result = [];
$.ajax({
url : "${ctx}medicalhistory/Type_select2",
async : false,
type : "get",
data : {"sign":"3"},
success : function(data) {
$.each(data.data,function(i,item){
var obj = {};
obj.id =item.ICDBM0;
obj.text = item.ICDBM0;
result.push(obj);
});
}
});
return result;
},
emptytext : "暂无",
select2 : {
//tags:true,
allowClear : true,
language: "zh-CN",
placeholder: '请选择ICD码',
width : '150px',//设置宽
id: function (item) {
return item.text;
}
}
}
},{
field: "XB0000",
title: "性别",
editable: {
type: "select",
separator:",",
source: [{ value: '2', text: '女性' },{ value: '1', text: '男性' },
{ value: '0', text: '不限' }],
}
},{
field: "",
title: "序号",
},{
field: "YXBZ00",
title: "有效标志",
editable: {
type: "select",
separator:",",
source: [{ value: '1', text: '有效' },
{ value: '0', text: '无效' }],
}
},{
field: "BZBH00",
title: "在线标准编码",
editable: {
type: 'text',
title: '在线标准编码',
emptytext : "暂无",
}
},{
field: "YSSM00",
title: "饮食说明(套餐)",
editable: {
type: 'text',
title: '饮食说明(套餐)',
emptytext : "暂无",
}
},{
field: "JLMC00",
title: "结论",
editable: {
type: 'select2',
title: '结论',
emptytext : "暂无",
name : 'JLMC00',
source : function () {//动态获取数据
var result = [];
$.ajax({
url : "${ctx}medicalhistory/Type_select2",
async : false,
type : "get",
data : {"sign":"4"},
success : function(data) {
$.each(data.data,function(i,item){
var obj = {};
obj.id =item.JLMC00;
obj.text = item.JLMC00;
result.push(obj);
});
}
});
return result;
},
emptytext : "暂无",
select2 : {
//tags:true,
allowClear : true,
language: "zh-CN",
placeholder: '请选择结论',
width : '150px',//设置宽
id: function (item) {
return item.text;
}
}
}
},{
field: 'operator',
title: '操作',
formatter: setformete
}],[
{
field: "BSLBMC",
title: "成人",
editable: {
type : 'select2',
title: '成人',
name : 'BSLBID',
source : function () {//动态获取数据
var result = [];
$.ajax({
url : "${ctx}medicalhistory/Type_select2",
async : false,
type : "get",
data : {"sign":"1"},
success : function(data) {
$.each(data.data,function(i,item){
var obj = {};
obj.id =item.LBMC00;
obj.text = item.LBMC00;
result.push(obj);
});
}
});
return result;
},
emptytext : "暂无",
select2 : {
//tags:true,
allowClear : true,
language: "zh-CN",
placeholder: '请选择病史类别',
width : '150px',//设置宽
id: function (item) {
return item.text;

...全文
1835 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
☞鵬 2020-07-26
  • 打赏
  • 举报
回复
请问你的样式正确吗?我这边在文本框一输入查询条件,样式就变了
weixin_39536750 2019-12-25
  • 打赏
  • 举报
回复
引用 3 楼 浅歌余生 的回复:
引用 2 楼 weixin_39536750 的回复:
请问解决了吗
实现方法是另写一个select去替换控件的select的但是样式很丑感觉不好
我这边用一个弹出框去代替了,这个插件真的坑多
沿途欣赏i 2019-12-19
  • 打赏
  • 举报
回复
引用 2 楼 weixin_39536750 的回复:
请问解决了吗
实现方法是另写一个select去替换控件的select的但是样式很丑感觉不好
weixin_39536750 2019-11-08
  • 打赏
  • 举报
回复
请问解决了吗

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧