Got an error while try to fill datatable with json data

Got an error while try to fill datatable with json data

Tejas91Tejas91 Posts: 4Questions: 1Answers: 0

I got alert popup with error message "DataTables warning: table id=example2 - Requested unknown parameter '1' for row 0. For more information about this error, please see http://datatables.net/tn/4"

But i am able to solve the issue behind it .

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • Tejas91Tejas91 Posts: 4Questions: 1Answers: 0

    Thanx for reply..
    Actually , i right now working locally. i dont have any link to provide you right now

  • Tejas91Tejas91 Posts: 4Questions: 1Answers: 0
    edited April 2016

    right now my json object reponse like :

     [Object { Date="26/04/2016",  Center="UNKNOW",  Area="GURUKUL",  more...}, Object { Date="26/04/2016",  Center="UNKNOW",  Area="GURUKUL",  more...}]
    

    which is as expected which i want , but after that i got alert message , which shows error
    "DataTables warning: table id=example2 - Requested unknown parameter '1' for row 0. For more information about this error, please see http://datatables.net/tn/4"

    my code for filling data table is

       $("#ContentPlaceholder1_drpdrs").change(function () {
                    $('#example2').show();
                    var drsnotext = $("#ContentPlaceholder1_drpdrs option:selected").text();
                    $.ajax({
                        type: "POST",
                        url: "NewDeliveryRunsheet.aspx/BindDatatable",
                        data: "{drpdrsvalue:'" + drsnotext + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            console.log(JSON.parse(data.d));
                            var dataset = data.d;
    
                            $("#example2").DataTable({
                                "paging": true,
                                "lengthChange": true,
                                "searching": true,
                                "ordering": true,
                                "info": true,
                                "autoWidth": true,
                                data: dataset,
                                columns : [
                                 { title: "Date" },
                                 { title: "Center" },
                                 { title: "Area" },
                                 { title: "DocumentNumber" },
                                 { title: "deliveryBoy" },
                                 { title: "DRSNo" },
                                 { title: "Receiver" }
                                ]
    
                            });
                        }
                    });
                });
    

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • Tejas91Tejas91 Posts: 4Questions: 1Answers: 0

    i used to apply to serveral type of code for binding a datatable , but got error

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Use columns.data to tell DataTables where to get the data, not columns.title. See also the manual page for this topic.

    This issue comes up a lot, it would be helpful to me if you could point out any documentation that made you use the wrong option so I can fix it.

    Allan

This discussion has been closed.