layui.table怎样给td添加select

layui.table怎样给td添加select,第1张

done:function(res,cur,count){

var ct=1

$("tbody td[data-field='robot'] .layui-table-cell").each(function(e,a){

ct++

var arry = new Array()

if(!util.isEmpty(a.innerText)){

arry = a.innerText.split(",")

}

$(a).html($(htmlSelects).attr("xm-select","robot"+ct)[0])

user.formSelects.render('robot' + ct , {

template: function(name, value, selected, disabled){

return value.name  //+ '<span style="position: absolute right: 0 color: #A0A0A0 font-size: 12px">' + name + '</span>'

}

})

user.formSelects.value('robot' + ct, arry)

user.formSelects.on('robot' + ct, function(id, vals, val, isAdd, isDisabled){

//id:           点击select的id

//vals:         当前select已选中的值

//val:          当前select点击的值

//isAdd:        当前 *** 作选中or取消

//isDisabled:   当前选项是否是disabled

//alert("当前选择了: " + JSON.stringify(vals))

var select =$("tbody div select[xm-select="+id+"]")

var tt =select.parent().parent().siblings()

var id=""

tt.each(function(e,a){

if($(a).attr("data-field")=="id") id=$(a).children().html()

})

var arr = new Array()

for ( var i = 0 i <vals.length i++){

arr.push(vals[i].value)

}

user.setRobot(id,arr)

}, true)

})

}

js实现:

layui.use(['table','form'],

function()

{

$

=

layui.jquery

table

=

layui.table

tableIns

=

initTable()

})

//加载列表

function

initTable(){

//

执行渲染

tableIns

=

table.render({

id:

'idTest',

elem

:

'#deviceTable',

//

指定原始表格元素选择器(推荐id选择器)

size:

'lg',

height

:

'full-20',

//

容器高度

url

:

'/csCloud-admin/deviceController/getDeviceList.do',

where:

{

'orgId':$("#orgId").val(),

'coldNum':$("#coldNum").val(),

'devType':$("#devType").val(),

'isUsed':$("#isUsedId").val()

},

method

:

'post',

cols

:

[

[

//

标题栏

{

field

:

'rownum',

title

:

'序号',

width

:

100,

sort

:

true

},

{

field

:

'devNum',

title

:

'设备编号',

width

:

200

},

{

field

:

'devAlias',

title

:

'设备别名',

width

:

100

},

{

field

:

'devTypeVal',

title

:

'设备类型',

width

:

100

},

{

field

:

'devModel',

title

:

'设备型号',

width

:

100

},

{

field

:

'stateVal',

title

:

'设备状态',

width

:

100

},

{

field

:

'coldNum',

title

:

'冷库编号',

width

:

100

},

{

field

:

'orgName',

title

:

'所属机构',

width

:

300

},

{

field

:

'isUsedValue',

title

:

'状态',

width

:

100

},

{

fixed

:

'right',

width

:

300,

align:'center',

toolbar

:

'#barDemo'

}

]

],

//

设置表头

page

:

true,

limits

:

[

10,30,

60,

90,

150,

300

],

limit

:

10

})

return

tableIns

}

jsp实现:

<div

class="layui-fluid">

<div

class="layui-row">

<div

class="layui-col-lg12">

<table

id="deviceTable"></table>

</div>

</div>

</div>

以上这篇layui实现table加载的示例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:layui的table单击行勾选checkbox功能方法layui实现点击按钮给table添加一行layui结合form,table的全选、反选v1.0示例讲解


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11261716.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存