【发布时间】:2023-03-28 10:29:01
【问题描述】:
我有一个 Handsontable 0.11.2 的实现,它接收 JSON 格式的数据。我已使列可排序,并且有一个数字列(我已将其定义为数字)仍然像字符串一样排序。我尝试通过将 .0 添加到结尾格式来使其成为浮点数,即使它显示为 0,它仍然作为字符串排序。我在 Google 搜索中看到了一些潜在的解决方案,但还没有找到可行的解决方案。我的实用设置如下,非常感谢任何建议。
$(document).on('click','.report',function(event) {
$.ajax({
type: "GET",
url: 'pending.php',
dataType: "json",
success: function(json) {
$('.item').remove();
$(".welcome").hide();
$(".carousel-inner").append("<div id='faTable'></div>");
var $container = $("#faTable");
var $parent = $container.parent();
$container.handsontable({
data: json.data,
startRows: 10,
startCols: 8,
rowHeaders: true,
manualColumnResize: true,
manualColumnMove: true,
columnSorting: true,
colHeaders: ['Lot','Number','Reason','Results','Billback','Status','Rank'],
contextMenu: true,
colWidths: [80,150,300,200,200,50,50],
columns: [
{data: "lot", type: 'text',readOnly: true},
{data: "number",type: 'text',readOnly: true},
{data: "reason", type: 'text',readOnly: true},
{data: "results", type: 'text',readOnly: true},
{data: "billback", type: 'text',readOnly: true},
{data: "status", type: 'text',readOnly: true},
{data: "rank", type: 'numeric',readOnly: true}
]
});
},
error: function(data) {
}
});
})
【问题讨论】:
标签: jquery json handsontable