unable to create datatable from data revceived via ajax

unable to create datatable from data revceived via ajax

mani.guptamani.gupta Posts: 4Questions: 1Answers: 0

Him Allan/all,
Need urgent help!!
I m fetching data from backend using ajax call. But I m unable to create datatable.

html:

Id Name Status

js:
var oTable = $('#partnerTable').dataTable({

                 "sAjaxSource": 'displayPartner.action',
                                     "dataType" : "json",

                "aoColumns" : [{
                    "infos" : "partnerId"
                }, {
                    "infos" : "partnerName"
                }, {
                    "infos" : "status"
                }]

            });

data received:
{
"countryInfos":null,
"currencyInfos":[
],
"infos":[
{
"address":null,
"partnerId":"AIRTEL02",
"partnerName":"AIRTEL INDIA",
"password":null,
"phNo":null,
"status":"ACTIVE",
"thDtls":null,
"thresholdsDtls":null,
"username":null
},
{
"address":null,
"partnerId":"DOCOMO",
"partnerName":"DOCOMO",
"password":null,
"phNo":null,
"status":"ACTIVE",
"thDtls":null,
"thresholdsDtls":null,
"username":null
},
{
"address":null,
"partnerId":"INAir1406018829076",
"partnerName":"Airtel India",
"password":null,
"phNo":null,
"status":"ACTIVE",
"thDtls":null,
"thresholdsDtls":null,
"username":null
}
],
"obj":{
},
"recSinks":[
],
"sendSinks":[
],
"thresholdInfos":null

}

I am getting error:
TypeError: f is undefined

please help....

Please help me ...

This question has an accepted answers - jump to answer

Answers

  • mani.guptamani.gupta Posts: 4Questions: 1Answers: 0

    I m using datatable1.10.4

  • abhinav.waseabhinav.wase Posts: 2Questions: 1Answers: 0

    Same pinch.. I too have similar problem,...

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Please link to a test page showing the issue, as required in the forum rules. If urgent help is required, there is also priority support available.

    Allan

  • mani.guptamani.gupta Posts: 4Questions: 1Answers: 0
    edited December 2014

    In simple terms, if my received data is:

    {
        "countryInfos": null,
        "currencyInfos": [],
        "infos": [
            {
                "address": null,
                "partnerId": "AIRTEL02",
                "partnerName": "AIRTEL INDIA",
                "password": null,
                "phNo": null,
                "status": "ACTIVE",
                "thDtls": null,
                "thresholdsDtls": null,
                "username": null
            },
            {
                "address": null,
                "partnerId": "DOCOMO",
                "partnerName": "DOCOMO",
                "password": null,
                "phNo": null,
                "status": "ACTIVE",
                "thDtls": null,
                "thresholdsDtls": null,
                "username": null
            },
            {
                "address": null,
                "partnerId": "INAir1406018829076",
                "partnerName": "Airtel India",
                "password": null,
                "phNo": null,
                "status": "ACTIVE",
                "thDtls": null,
                "thresholdsDtls": null,
                "username": null
            }
        ],
        "obj": {},
        "recSinks": [],
        "sendSinks": [],
        "thresholdInfos": null
    }
    

    Using the above data, how to create a dataTables with three columns : Partner Id, Partner Name and Status.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Use the ajax.dataSrc option and set it to be infos. Then for each column use columns.data and set it to be partnerId, etc.

    Allan

  • mani.guptamani.gupta Posts: 4Questions: 1Answers: 0

    Thanks alot Allan, it resolved the issue. The dataTable is indeed one of the coolest js plugin.Feeling to explore it more. Grt work!!!:)

This discussion has been closed.