user2472968
user2472968

Reputation: 405

How to achieve dynamic data in a table/grid in jquery

I aim to create a cricket score board where the data is updated real time. I am have two techniques in mind one I have used jquery grid plugin for this. Which will get the data via JSON. Code is below. The other is making an html table and putting JSP scriplets in table rows and fetch the data probably by ajax. The draw back with this is I don't get the grid feel on the view. It's just a simple table.

  <script type="text/javascript">

    $(function(){
    var data = [ ['Player1'],
        ['Player2'],
        ['Player3','',''],
        ['Player4','',''],
        ['Player5','',''],
        ['Player6','',''],
        ['Player7','',''],
        ['Player8','',''],
        ['Player9','',''],
        ['Player10','',''],
        ['Player11','','']];

    var obj = {};
    obj.width = 700;
    obj.height = 400;
    obj.colModel = [{title:"Batsman", width:100, dataType:"integer"} ,
                {title:"", width:394, dataType:"string"},
    {title:"balls", width:10, dataType:"string"},
    {title:"runs", width:10, dataType:"float", align:"right"},
    {title:"strikerate", width:10, dataType:"float", align:"right"}];
    obj.dataModel = {data:data};
    $("#grid_array").pqGrid( obj );                                

   });

   </script>

Can anyone advise me the correct and less complicated way of achieving this. I need the grid like feel on the view.

Upvotes: 0

Views: 1146

Answers (1)

Pranav Kale
Pranav Kale

Reputation: 639

I would recommend using JQuery Grid Plugin (JQGrid).. It easy to configure and use.This two sites will help you with that:-

http://trirand.com/blog/jqgrid/jqgrid.html

http://www.trirand.com/jqgridwiki/doku.php

Also it is bad practice to use java code (scriplets) inside JSP so try and avoid it as far as possible.

Upvotes: 1

Related Questions