Dolle
Dolle

Reputation: 31

Push data to array populate jqGrid

Im try to populate my JQgrid with data each time I press the button "1" but I dont know what Im doing wrong. Im new to jquery. I have no problem printing the data to a p tag.

Im trying to use push should I use add instead? Or do I need to refresh the grid every press.

Any other suggested solutions are welcome.

     $(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());

        });

    }

 }

Upvotes: 0

Views: 767

Answers (1)

Dolle
Dolle

Reputation: 31

My solution:

jQuery("#table_list_1").addRowData("1",{id: id, time: wavesurfer.getCurrentTime()});

Upvotes: 1

Related Questions