DataTables in Salesforce

DataTables in Salesforce

ArpitRaoArpitRao Posts: 2Questions: 0Answers: 0
edited December 2012 in General
I want to add dynamic columns as per the server response.
I am getting the AJAX response from server but not sure how to set datatables


var j$ = jQuery.noConflict();
j$(document).ready(function(){
// Make the Ajax Request
j$.getJSON("{!$Page.AjaxResponder}", {
"core.apexpages.devmode.url" :'1',
"q" :"0019000000AYjFj"
}, function(data) {
alert(JSON.stringify(data));
});
var oTable = j$('#example').dataTable( {
"sDom": '<"top"i>RT<"clear">lrpftS',
"sScrollY": "240px",
"sScrollX": "100%",
"sScrollXInner": "140%",
"oTableTools": { "sSwfPath": "{!URLFOR($Resource.DataTables, 'DataTables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf')}" }
} );
new FixedHeader( oTable );
});


<!-- Main Table (This section should be dynamic as per the Content Columns requested from Main Page -->














AJAX response from Server
[Code]
[{"attributes":{"type":"Contact","url":"/services/data/v26.0/sobjects/Contact/0039000000AgUwlAAF"},"Id":"0039000000AgUwlAAF","Name":"Jack Rogers","Email":"jrogers@burlington.com"}
[/code]

Replies

  • ArpitRaoArpitRao Posts: 2Questions: 0Answers: 0
    var j$ = jQuery.noConflict();
    j$(document).ready(function(){
    // Make the Ajax Request
    j$.getJSON("{!$Page.AjaxResponder}", {
    "core.apexpages.devmode.url" :'1',
    "q" :"0019000000AYjFj"
    }, function(data) {
    alert(JSON.stringify(data)); //Getting JSON response
    });
    var oTable = j$('#example').dataTable( {
    "sDom": '<"top"i>RT<"clear">lrpftS',
    "sScrollY": "240px",
    "sScrollX": "100%",
    "sScrollXInner": "140%",
    "oTableTools": { "sSwfPath": "{!URLFOR($Resource.DataTables, 'DataTables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf')}" }
    } );
    new FixedHeader( oTable );
    });


    <!-- Main Table (This section should be dynamic as per the Content Columns requested from Main Page -->
  • allanallan Posts: 63,530Questions: 1Answers: 10,474 Site admin
    What does the Ajax response look like?

    Also please see: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
This discussion has been closed.