Javascript 需要som ehelp为Datatable提供此子滑块
我正在处理一个数据表。当我将Json传递给函数时,它肯定在那里。 返回,子行滑动,但显示未定义。我试过几种方法。有什么想法吗?这对我来说是全新的Javascript 需要som ehelp为Datatable提供此子滑块,javascript,datatables,slider,rows,Javascript,Datatables,Slider,Rows,我正在处理一个数据表。当我将Json传递给函数时,它肯定在那里。 返回,子行滑动,但显示未定义。我试过几种方法。有什么想法吗?这对我来说是全新的 <script> function format ( object ) { let data=object; let x = ''; let txt=''; console.log(object); //data=object; try { if (x != undefined)
<script>
function format ( object ) {
let data=object;
let x = '';
let txt='';
console.log(object);
//data=object;
try {
if (x != undefined) {
// Executes for declared variables that are not undefined nor null
console.log( 'X is okay ' + x)
} // (Nothing happens)
} catch (x) {
console.log('Catch ' + x) // ReferenceError: x is not defined
}
//Json.parse(data);
for (x in data) {
txt += data[x].Tillid + ' Line No:' + data[x].LineNo + ' ' +data[x].Productcode + ' ' + data[x].ProductDescription+' ' + parseFloat(data[x].LineSalePriceIncDisc).toFixed(2) +"\n";
return '<div class="slider">'+
'<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Till Name:</td>'+
'<td>'+ data[x].Tillid + '</td>'+
'<td>Customers Invoices:</td>'+
'<td>'+''+'</td>'+
'</tr>'+
'<tr>'+
'<td>Customer Name:</td>'+
'<td>'+ console.log(data[x].Tillid) +'</td>'+
'</tr>'+
'<tr>'+
'<td>Extra info:</td>'+
'<td>And any further details here (images etc)...</td>'+
'</tr>'+
'</table>';
}
}
</script>```
example of data below:
{Tillid: "MAINTILL", LineNo: "1", Productcode: "15479", ProductDescription: "Cadent 1 Blk Lagre", SingleSalePrice: "380.0000", …}
{Tillid: "MAINTILL", LineNo: "2", Productcode: "11571", ProductDescription: "Helm 58-62 Mission EVO Silver", SingleSalePrice: "19.9900", …}
函数格式(对象){
让数据=对象;
设x='';
设txt='';
console.log(对象);
//数据=对象;
试一试{
如果(x!=未定义){
//为未定义或非空的声明变量执行
console.log('X正常'+X)
}/(什么也没发生)
}捕获(x){
console.log('Catch'+x)//引用错误:未定义x
}
//Json.parse(数据);
对于(数据中的x){
txt+=数据[x]。Tillid+'行号:'+data[x]。行号+'+data[x]。产品代码+'+data[x]。产品描述+'+parseFloat(数据[x]。LineSalePriceIncDisc)。toFixed(2)+“\n”;
返回“”+
''+
''+
'直到名称:'+
''+数据[x].Tillid+''+
'客户发票:'+
''+''+''+
''+
''+
'客户名称:'+
''+控制台.log(数据[x].Tillid)+''+
''+
''+
'额外信息:'+
'以及此处的任何进一步细节(图像等)…'+
''+
'';
}
}
```
以下数据示例:
{Tillid:“MAINTILL”,行号:“1”,产品代码:“15479”,产品描述:“Cadent 1 Blk Lagre”,SingleSalePrice:“380.0000”,…}
{Tillid:“MAINTILL”,行号:“2”,产品代码:“11571”,产品描述:“Helm 58-62 Mission EVO Silver”,SingleSalePrice:“19.9900”,…}