DataTables in Salesforce
DataTables in Salesforce
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]
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]
This discussion has been closed.
Replies
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 -->
Also please see: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
Allan