Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35416

Data Table crashes for records above 40

$
0
0

I am using data table to display data returned by a SQL Server 2008 procedure called in Codeigniter via Ajax($POST). Initially I made a very simple procedure with no input parameters, it only returns a list of JSON objects. Below are my questions and my Codeigniter function returning JSON, AJAX function and JSON structure returned by my Codeigniter function .:

1) When my JSON data size goes above 45+ , it crashes and gives me below error. It works fine for data below 40(Which does not make sense as i have to display much larger around 1000+ records)(one more thing i noticed in my fire bug when i return more then 40 records i dont see a json tab in my fire bug console it only says html where i returned json encoded data):

DataTables warning: table id=example - Requested unknown parameter 'AppointmentID' for row 0. For more information about this error, please see http://datatables.net/tn/4

2) What if one of my procedure returns lets say 5000+ record and i want to display it in data table, is my way of doing it right? Or i should use some other best practices:

public function executeProc()
 {
    $sqlsrvr = $this->load->database('test', true);

    // Get the input values of the procedure

    $arr = array();
    parse_str($_POST['str'],$arr);

    //get Procedure Name
    $procName = $_POST['procName'];

    $sp ='exec secondProc';
    $query = $sqlsrvr->query($sp);//->result();
    $jawad =  $query->result_array();

    $this->output->set_header('Content-type: application/json');
     echo json_encode($jawad);

 }

AJAX function

$(document).on('click','#executeProc',function(e){

$('#demo').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>');
  e.preventDefault();

  var jawad = $( ".jawad" ).serialize();

 $.post('<?=base_url();?>command/executeProc',
    {str:jawad,procName:$('#procName').val()},

   function(html){
    //loading data table on return
    $('#example').dataTable( {
     "data": html,
    "columns": [
        { "data": "AppointmentID" },
        { "data": "FirstName" },
        { "data": "LastName" },
        { "data": "AppointmentDate" }
    ]
  } );

    });

});

JSON STRUCTURE:

[
    {
        "AppointmentID": "1",
        "FirstName": "Test",
        "LastName": "test",
        "AppointmentDate": "2013-01-12"
    },
    {
        "AppointmentID": "2",
        "FirstName": "dfg",
        "LastName": "dfg",
        "AppointmentDate": "2013-01-01"
    }
]

Viewing all articles
Browse latest Browse all 35416

Trending Articles