layui数据表格显示图片,以及单元格信息超出后鼠标悬停显示

JS:

	var tableIns = table.render({
		elem:'#test'
		,url:'${ctx}/product/getProductsByPage'	//数据接口
		,toolbar:'#toolbarDemo'		//外部标签引用
		,defaultToolbar:['filter','exports','print'] //排序,导出,打印
		,even:true	//隔行背景
		,title: '产品数据表'
		,id:'productId'
		,cols:[[//表头	
			{field:'iD', title:'ID', width:50, align:'center', sort:true}
			//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ templet定义封面 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
			,{field:'coverPicPath',title:'产品封面' ,width:130, event:'setSign',align:'center',
					 templet:'
'
} ,{field:'productName',title:'产品名称' , align:'center'} ,{field:'productCode',title:'产品编号' , width:120, align:'center'} ,{field:'productType',title:'产品类型' , width:120, align:'center' ,templet:function(d){ if(d.productType == 1){ return "破碎设备"; }else if(d.productType == 2){ return "筛分设备"; }else if(d.productType == 3){ return "制沙设备"; } }} ,{fixld:'right', title:'操作', align:'center',toolbar:'#barDemo',} ]] ,done:function(res){ tdTitle(); } //调用鼠标悬停显示单元格信息的方法 ,page:true //开启分页 ,limit: 10 }); function tdTitle(){ $('th').each(function(index,element){ $(element).attr('title',$(element).text()); }); $('td').each(function(index,element){ $(element).attr('title',$(element).text()); }); };

CSS(根据单元格显示调节)

<style type="text/css">
    .layui-table-cell{
		text-align:center;
        height: 60px;
        line-height: 4px;
      	white-space:normal;
    }
</style>

你可能感兴趣的:(layui数据表格)