weixin_33726318 2019-01-01 20:29 采纳率: 0%
浏览 21

一列显示数据

I am working with jQuery datatables. I am executing the following sql statement:

SELECT status, internal_id, name, address, city, id FROM `relations` 

With the option columnDefs I am trying to show the data in a specific column: columnDefs targets 0 created the column for 'status' columnDefs targets 1 created the column for 'internal_id' etc.

Now what I want is I want to show the data for "name", "address" and "city" in one column. In SQL I can realize this by using concat. But this is not what I want. I want define the columns in columnDefs so I will be able to change the style of the data.

Does someone know what I need to change in my jQuery to put the "name", "address" and "city" in one column?

Here is my jQuery:

<script type="text/javascript">
  $( document ).ready(function() {
    $('#employee_grid1').DataTable({
      "bprocessing": true,
      "serverSide": true,
      "ajax": {
    "url": "response1.php",
    "type": "POST",
    "error": function(){
      $("#employee_grid_processing").css("display","none");
    }
      },
      "columnDefs": [ 
    { "targets": 0, "render": function ( data, type, full, meta ) { return  ' ' + (data == 0 ? '<center ><i class="fa fa-university" aria-hidden="true"></i>' : (data == 1 ? '<i class="fa fa-university" aria-hidden="true"></i>' : '<i class="fa fa-briefcase" aria-hidden="true"></i>')) + ' '} },
    { "targets": 1, "render": function ( data, type, full, meta ) { return  '<center>'+data+'</center>'} },
    { "targets": 2, "render": function ( data, type, full, meta ) { return  '<table><tr><td>'+data+'</td></tr>'} },
    { "targets": 3, "render": function ( data, type, full, meta ) { return  '<td>'+data+'</td>'} },
    { "targets": 4, "render": function ( data, type, full, meta ) { return  '<td>'+data+'</td></table>'} }              
      ]                
    });   
  });
</script>
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8
      • ¥15 安卓时间管理APP,怎么做
      • ¥15 这段有什么bug 为什么总报错
      • ¥15 Intel Realsense深度相机(D415/D435)拍摄梯子获取梯子点云