Javascript 数据表数字转换为八进制
在数据表中,我面临一个挑战 我有一个前导零的数字(0461)。数据在数据表中正确显示,但当我单击该数字并传入一个方法时,它将转换为另一个数字,可能是八进制数 例如,将0461转换为86 请提出一些建议 我的数据表代码是Javascript 数据表数字转换为八进制,javascript,datatables,Javascript,Datatables,在数据表中,我面临一个挑战 我有一个前导零的数字(0461)。数据在数据表中正确显示,但当我单击该数字并传入一个方法时,它将转换为另一个数字,可能是八进制数 例如,将0461转换为86 请提出一些建议 我的数据表代码是 var table = $('#example').DataTable({ processing : true, serverSide : true, pageLength : 10,
var table = $('#example').DataTable({
processing : true,
serverSide : true,
pageLength : 10,
ajax : {
url : "/codes",
data : function(data) {
}
},
columns : [ {
"data" : "code",
"name" : "Code",
"title" : "Code",
"render" : function(data) {
// From here I am passing 0461
return '<a class="link" onclick="return searchCode('+data+');">' + data + '</a>';
}
} ],
columnDefs : [ {
"targets" : [ 1],
"searchable" : false
}, {
"targets" : [ 0],
"orderable" : true
} ]
});
// But here getting 86
function searchCode(code) {
console.log(code);
}
var table=$('#示例').DataTable({
处理:对,
服务器端:是的,
页长:10,
阿贾克斯:{
url:“/code”,
数据:函数(数据){
}
},
列:[{
“数据”:“代码”,
“名称”:“代码”,
“标题”:“代码”,
“渲染”:函数(数据){
//从这里我经过0461
返回在解决方案下面找到的“”
var table = $('#example').DataTable({
processing : true,
serverSide : true,
pageLength : 10,
ajax : {
url : "/codes",
data : function(data) {
}
},
columns : [ {
"data" : "code",
"name" : "Code",
"title" : "Code",
"render" : function(data) {
// From here passing this instead of data
return '<a class="link" onclick="return searchCode(this);">' + data + '</a>';
}
} ],
columnDefs : [ {
"targets" : [ 1],
"searchable" : false
}, {
"targets" : [ 0],
"orderable" : true
} ]
});
// It will print what we will pass from above method
function searchCode(code) {
console.log(code.text); // print 0461
}
var table=$('#示例').DataTable({
处理:对,
服务器端:是的,
页长:10,
阿贾克斯:{
url:“/code”,
数据:函数(数据){
}
},
列:[{
“数据”:“代码”,
“名称”:“代码”,
“标题”:“代码”,
“渲染”:函数(数据){
//从这里传递这个而不是数据
返回“”+数据+“”;
}
} ],
columnDefs:[{
“目标”:[1],
“可搜索”:false
}, {
“目标”:[0],
“可订购”:真
} ]
});
//它将打印我们将从上述方法传递的内容
函数搜索代码(code){
console.log(code.text);//打印0461
}
找到下面的解决方案
var table = $('#example').DataTable({
processing : true,
serverSide : true,
pageLength : 10,
ajax : {
url : "/codes",
data : function(data) {
}
},
columns : [ {
"data" : "code",
"name" : "Code",
"title" : "Code",
"render" : function(data) {
// From here passing this instead of data
return '<a class="link" onclick="return searchCode(this);">' + data + '</a>';
}
} ],
columnDefs : [ {
"targets" : [ 1],
"searchable" : false
}, {
"targets" : [ 0],
"orderable" : true
} ]
});
// It will print what we will pass from above method
function searchCode(code) {
console.log(code.text); // print 0461
}
var table=$('#示例').DataTable({
处理:对,
服务器端:是的,
页长:10,
阿贾克斯:{
url:“/code”,
数据:函数(数据){
}
},
列:[{
“数据”:“代码”,
“名称”:“代码”,
“标题”:“代码”,
“渲染”:函数(数据){
//从这里传递这个而不是数据
返回“”+数据+“”;
}
} ],
columnDefs:[{
“目标”:[1],
“可搜索”:false
}, {
“目标”:[0],
“可订购”:真
} ]
});
//它将打印我们将从上述方法传递的内容
函数搜索代码(code){
console.log(code.text);//打印0461
}
尝试在您传入的数据参数周围添加双引号。返回searchCode(“+data+”);
尝试在一个参数上方添加双引号,但未获得语法错误:InputCTAL“0461”的意外结尾将是305小数点正确。。任何解决方案尝试在您传入的数据参数周围添加双引号。返回searchCode>(“'+data+'”;
尝试了上述方法,但未获得正确的语法错误:InputCTAL“0461”的意外结尾将是305位小数。是否有解决方案