You need to sign in to do that
Don't have an account?
-_-
JS Remoting to fetch data for bootstrap-table plugin not working
Hi I am trying to dynamically make a remoting call to an action function to query some data, serialize it to JSon and return it to the page for jQuery and the bootstrap table plugin to dynamically update the table.
It seems what is happening is the remote action is returning sooner than the table is being rendered (at least that's the only explination I have) and therefore the table is never rendering even though all my validations are showing that the JSON data is being returned successfully.
Has anyone faced this type of issue before? Below is the code:
Relevant portion of Page:
Relevant JS:
Action method (pleaes excuse the hardcoding, just a draft atm):
It seems what is happening is the remote action is returning sooner than the table is being rendered (at least that's the only explination I have) and therefore the table is never rendering even though all my validations are showing that the JSON data is being returned successfully.
Has anyone faced this type of issue before? Below is the code:
Relevant portion of Page:
<table id="table" > <thead> <tr> <th data-field="Wait List">Wait List</th> <th data-field="Status">Status</th> <th data-field="Enrollment Date/Time">Enrollment Date/Time</th> </tr> </thead> </table>
Relevant JS:
var $j = jQuery.noConflict(); $j(document).ready(function() { $j('#noWL').hide(); $j('#waitLists').hide(); astro.RADLandingCtrlr.getWaitList(function(result, event){ if (event.status) { if(result == '[]'){ console.log('RESULT: ' + result); $j('#noWL').show(); }else { myData = he.decode(result); console.log('RESULT: ' + he.decode(result)); $j('#waitLists').show(); $j('#table').bootstrapTable({ data : he.decode(result) }); } }else if(event.type === 'exception'){ $j('#showmsg').val(event.message + "<br/>\n<pre>"+event.where+"</pre>"); } else { $j('#showmsg').val(event.message); } },{ buffer: false, escape: true, timeout: 30000 } ); });
Action method (pleaes excuse the hardcoding, just a draft atm):
@RemoteAction global static String getWaitList(){ set<Id> idSet = new set<Id>(); List<applicationStatus> apps_list = new List<applicationStatus>(); idSet.add(UserInfo.getUserId()); idSet.add('003i000004ew75Q'); String contId_str = ''; for(User usr : [select ContactId, Id from user where Id IN :idSet]){ if(usr.contactId != null){ contId_str = usr.contactId; }else { contId_str = '003i000004ew75Q'; } } system.debug('contId_str: ' + contId_str); for(astro__Wait_List_Selection__c waitList : [select Id, astro__Applications__c, astro__Applications__r.astro__Application_Status__c, astro__Applications__r.CreatedDate, astro__Wait_List_Type__c, astro__Wait_List_Type__r.Name from astro__Wait_List_Selection__c where astro__Applications__r.astro__Applicant__c = :contId_str AND astro__Applications__r.astro__Application_Status__c NOT IN ('Submitted','Rejected')]){ applicationStatus appStatus = new applicationStatus(); appStatus.enrollment_dt = waitList.astro__Applications__r.CreatedDate; appStatus.waitList_str = waitList.astro__Wait_List_Type__r.Name; appStatus.status_str = waitList.astro__Applications__r.astro__Application_Status__c; apps_list.add(appStatus); } String return_str = JSON.serialize(apps_list); return_str = return_str.replaceAll('enrollment_dt', 'Enrollment Date/Time'); return_str = return_str.replaceAll('waitList_str', 'Wait List'); return_str = return_str.replaceAll('status_str', 'Status'); system.debug(return_str); return return_str; }
Does anyone know how they have dealt with this on their projects? I have tried the jquery Wait, then, do methods to no avail either.