Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82042

set JQuery Datatable data source with JSON returned from ASP.Net server

$
0
0
Hello, hope you are doing fine.
I am working with JQuery Datatable with html table in ASP.Net. The data is returned from ASP.Net server in form of JSON.
Here is the form of JSON.

[{"ID":4855,"CustomerID":57,"SupplierTypeID":null,"CustomerTypeID":153,"StartTime":"2012-01-18T04:50:38","EndTime":"2012-01-18T04:51:10","Duration":0.30,"DestinationID":10848,"Code":200,"CalledNumber":"492311371037","RawCalledNumber":"a116492311371037","ChargingByAma":1,"SupplierIPDomain":"213.240.158.16","IP":"93.185.139.149","OwnerDN":"38733240069","E101_CallAcceptingPartyNumber":"38733240069","CallStatus":"16","SysLogCode":"700","SipCauseCode":"200","SourceName":"Iswitch_111","OriginCodec":"PCMA@8000hz","DestinationCodec":"PCMA@8000hz","SupplierName":null,"CarrierType":1,"CarrierID":57,"NAME":"Telekom Slovenije","ServiceName":"Premium","TrunkGroup":"ASLLI,ASLMI","ServiceID":1,"ServiceType":1,"DestinationName":"Germany","SupplierServiceName":"Unknown"},{"ID":5872,"CustomerID":57,"SupplierTypeID":null,"CustomerTypeID":153,"StartTime":"2012-01-18T07:35:24","EndTime":"2012-01-18T07:50:04","Duration":14.60,"DestinationID":10848,"Code":200,"CalledNumber":"497612826777","RawCalledNumber":"a116497612826777","ChargingByAma":1,"SupplierIPDomain":"213.240.158.16","IP":"93.185.139.149","OwnerDN":"38643785358","E101_CallAcceptingPartyNumber":"38643785358","CallStatus":"16","SysLogCode":"700","SipCauseCode":"200","SourceName":"Iswitch_111","OriginCodec":"PCMA@8000hz","DestinationCodec":"PCMA@8000hz","SupplierName":null,"CarrierType":1,"CarrierID":57,"NAME":"Telekom Slovenije","ServiceName":"Premium","TrunkGroup":"ASLLI,ASLMI","ServiceID":1,"ServiceType":1,"DestinationName":"Germany","SupplierServiceName":"Unknown"},


Now I have html table like this:

<table id="example">
                                            <thead>
                                                <tr>
                                                    <th>
                                                        name
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <td>
                                                    
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>

And JQuery Ajax call is:


$.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            //timeout: 60000,
            url: "../WebServices/CDRStatistics.asmx/LoadStatisticsDetailInfoByJSON",
            data: "{'path': 'ReportManagement/Controls/ReleaseCauseForEmail.ascx', 'Code': " + $(this).parent().find('[id$=hdReleaseCauseCode]').val()
                + ", 'Hour': 0, 'pageIndex':" + pageIndex + ", 'pageSize':" + pageSize + "}",
            success: function (result) {
                //alert(result.d);
                $('[id$=_UpdateProgress1]').hide();
                gvReleaseCauseEmail = $('[id$=example]').dataTable({ "oLanguage": { "sSearch": 'Search keyword:&nbsp;&nbsp;' },
                    "aaData": result.d,
                    "aoColumns": [{"mData":"SupplierServiceName"}]
                });

                $('#divTroubleTicketCDR').find('table').first().width(1100);

                $('#divTroubleTicketCDR').css("left", Math.max(0, (($(window).width() - $('#divTroubleTicketCDR').outerWidth()) / 2) +
                                                $(window).scrollLeft()) + "px");

                $('#divTroubleTicketCDR').show();
                return false;
            },
            error: function (xhr) {
                alert(xhr.responseText);
                $('[id$=_UpdateProgress1]').hide();
            }
        });


Nothing is working. Where I am doing mistake. How can I pass JSON to JQuery Datatable aaData. Please correct my mistake.

Viewing all articles
Browse latest Browse all 82042

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>