简体   繁体   English

向数据表中的数据添加字母

[英]Add letters to data in datatables

I receive data with this format: 我收到以下格式的数据:

var options = {
    "dom": '<t"bottom"lp>',
    "scrollY": "400",
    "scrollCollapse": true,
    "paging": false,
    "searching": false,
    "info": false,
    'columns': head,
    'data': tableModal,
    "lengthChange": false,
}

tableModal come from PHP but I would like add letters after the data, in this case "s" because the data are seconds, but I don't know how to do it. tableModal来自PHP,但我想在数据后添加字母,在这种情况下为“ s”,因为数据是秒,但我不知道该怎么做。

Thanks for help. 感谢帮助。

how about this 这个怎么样

var options = {
    "dom": '<t"bottom"lp>',
    "scrollY": "400",
    "scrollCollapse": true,
    "paging": false,
    "searching": false,
    "info": false,
    'columns': {s:'s'},
    'data': [1,2],
    "lengthChange": false,
}

options['datas']=options['data']
delete options['data']

Check out this example. 看看这个例子。 Below is the code snippet performing this operation of adding S. 下面是执行此加S操作的代码段。

function appendS(){
    $.each(options.data, function(index, data){
      options.data[index] = options.data[index]+'s';
    })
  }

If you are using this data on charts, please use appropriate formatter instead of going for this approach. 如果您在图表上使用此数据,请使用适当的格式化程序,而不要使用此方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM