每次按下按钮“1”时,我都会尝试用数据填充我的 JQgrid,但我不知道我做错了什么。我是 jquery 新手。将数据打印到 p 标签没有问题。
我正在尝试使用推送,我应该使用添加吗?或者我是否需要每次按下都刷新网格?
欢迎任何其他建议的解决方案。
$(document).ready(function () {
// Examle data for jqGrid
var currentTime = [
{time:""} ,
];
// Configuration for jqGrid Example 1
$("#table_list_1").jqGrid({
data: currentTime,
datatype: "local",
height: 250,
autowidth: true,
shrinkToFit: true,
rowNum: 14,
rowList: [10, 20, 30],
colNames: ['Time'],
colModel: [
{name: 'time', index: 'time', width: 60, sorttype: "double"},
],
pager: "#pager_list_1",
viewrecords: true,
caption: "Example jqGrid 1",
hidegrid: false
});
// Add responsive to jqGrid
$(window).bind('resize', function () {
var width = $('.jqGrid_wrapper').width();
$('#table_list_1').setGridWidth(width);
});
});
window.addEventListener('keydown', doKeyDown, false);
function doKeyDown(e){
if(e.keyCode == 49 & wavesurfer.isPlaying()){
// KEY = " 1 "
currentTime.push(wavesurfer.getCurrentTime());
});
}
}
最佳答案
我的解决方案:
jQuery("#table_list_1").addRowData("1",{id: id, time: wavesurfer.getCurrentTime()});
关于javascript - 将数据推送到数组填充 jqGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36838812/