[英]manage data to Array in datatable
I have a few problem when I get all data from datatable jquery its not in array that I want.Below is my code, 当我从数据表jquery中获取所有数据时,我遇到了一些问题,它不在我想要的数组中。下面是我的代码,
var cells = [];
var rows = $("#PtptnFileTblId_1").dataTable().fnGetNodes();
for(var ii = 0; ii < rows.length;ii++)
{
for(var i = 1; i < 15 ;i++){
cells.push($(rows[ii]).find('td:eq('+ i +')').html());
}
}
console.log(cells);
when I see the console log ,the data show like this : 当我看到控制台日志时,数据显示如下:
["0000000000", "BP4", "99", "00987799201502", "SB1302BD2613", "911224126057", "Test1", "00791740", "zxa", "000000", "00000000", "null", "null", "10016020876162", "0000000000", "BP4", "59", "01678059201502", "MC1411BC8301", "940627146418", "Test2", "00672980", "qwq", "000000", "00000000", "null", "null", "12131023048090", "0000000000", "BP4", "13", "01482513201502", "SB1409BD7872", "910120126189", "Test3", "00672894", "AU", "000000", "00000000", "null", "null", "10016020934832"]
But the way I want is , 但是我想要的是
[Array[15], Array[15], Array[15]
0:[Array[15]
0:"0000000000"
1:"BP4"
2:"99"
3:"00987799201502"
4:"SB1302BD2613"
5:"12121312"
6:"TEST1"
7:"00791740"
8:"zxa"
9:"000000"
10:"00000000"
11:"null"
12:"null"
13:"10016020876162"
2:[Array[15]
0:"0000000000"
1:"BP4"
2:"99"
3:"00987799201502"
4:"SB1302BD2613"
5:"12121312"
6:"TEST1"
7:"00791740"
8:"zxa"
9:"000000"
10:"00000000"
11:"null"
12:"null"
13:"10016020876162"
3:[Array[15]
0:"0000000000"
1:"BP4"
......
Please anyone help me how I want to turn my code like the way I show above .This is my first time using jquery function like .push() .So is it any possible way.Any help will greatly appreciate.Thanks you 请任何人像我上面显示的方式帮助我如何转换代码。这是我第一次使用.push()之类的jquery函数,因此有任何可能的方式。任何帮助将不胜感激。谢谢
array.splice(0, 15)
will take 15 elements from the array each time. array.splice(0, 15)
每次都会从数组中获取15个元素。
var arr = ["0000000000", "BP4", "99", "00987799201502", "SB1302BD2613", "911224126057", "Test1", "00791740", "zxa", "000000", "00000000", "null", "null", "10016020876162", "0000000000", "BP4", "59", "01678059201502", "MC1411BC8301", "940627146418", "Test2", "00672980", "qwq", "000000", "00000000", "null", "null", "12131023048090", "0000000000", "BP4", "13", "01482513201502", "SB1409BD7872", "910120126189", "Test3", "00672894", "AU", "000000", "00000000", "null", "null", "10016020934832"] var result = []; while(arr.length) { result.push(arr.splice(0,15)); } console.log(result);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.