You need to sign in to do that
Don't have an account?
Rerender with jqGrid issue. PLEASE HELP
I am pulling my hair out with this one.
I have a few jqGrids on my VF page. I now have a select list Im using to try to filter one of the jqGrids. If I hardcode an ID in the controller to filter with, it works, and the grid reloads, but if i try to use the parameter that I am passing in via an ActionFunction, the logs show my parameter as null.
jquery change method
jQuery('[id$=htmlSelect]').change(function(e) { filterPage(this.value); var commGrid = jQuery('#commList'); commGrid.trigger("reloadGrid"); });
Action Function
<apex:actionFunction name="filterPage" action="{!makeNewCommJSON}" > <apex:param name="acc" value="" assignTo="{!stringID}"/>
</apex:actionFunction>
Controller function to filter list
public void makeNewCommJSON(){ Id acc = system.currentPageReference().getParameters().get('acc'); system.debug('accountid Parameter: ' + acc); system.debug('stringID Value: ' + stringID); list<Commitment__c> comms = [select id, Name, Due_Date__c, Status__c, Account__c, Account__r.Name, Owner__c, Owner__r.Alias from Commitment__c where Owner__c = :Userinfo.getuserid() and Status__c != 'Completed' and Account__c =: acc]; //and Account__c = '001M000000JKGcNIAX']; if(comms != null && comms.size() > 0) { newCommJSON = '{"page":"1","total":"' + ( 1 + ( comms.size() / 10 )) + '","records":"' + String.valueOf(comms.size()) + '","rows":['; for(Commitment__c c : comms ) { newCommJSON += '{"id":"' + c.id + '","cell":['; newCommJSON += JqGridDataController.parseCell(c.Due_Date__c); newCommJSON += JqGridDataController.parseCell('<a href=/'+ c.Account__c + '>'+ c.Account__r.Name +'</a>') newCommJSON += JqGridDataController.parseCell(c.Owner__r.Alias); newCommJSON += JqGridDataController.parseCell('<a href=/'+ c.Id + '>' + c.Name + '</a>'); newCommJSON = newCommJSON.subString(0,newCommJSON.length() - 1); newCommJSON += ']},'; } newCommJSON = newCommJSON.subString(0,newCommJSON.length() - 1); newCommJSON += ']}'; } else { //no records were retrieved newCommJSON = '{"page":"1","total":1,"records":"' + String.valueOf('0') + '","rows":['; newCommJSON += '],"userdata":{"amount":3220,"tax":342,"total":3564,"name":"Totals:"}}'; } DashIdCarrier.commJSONString = newCommJSON; }
This all works fine, but as I said, when I check the logs, the parameter isnt being passed properly. see below
17:56:00.082 (82279000)|SYSTEM_METHOD_EXIT|[33]|String.valueOf(Object) 17:56:00.082 (82302000)|SYSTEM_METHOD_ENTRY|[33]|System.debug(ANY) 17:56:00.082 (82313000)|USER_DEBUG|[33]|DEBUG|accountid Parameter: null 17:56:00.082 (82320000)|SYSTEM_METHOD_EXIT|[33]|System.debug(ANY) 17:56:00.082 (82341000)|METHOD_ENTRY|[34]|01pM00000009QmO|CommitmentDashboardController.__sfdc_stringID() 17:56:00.082 (82377000)|METHOD_EXIT|[34]|01pM00000009QmO|CommitmentDashboardController.__sfdc_stringID() 17:56:00.082 (82395000)|SYSTEM_METHOD_ENTRY|[34]|System.debug(ANY) 17:56:00.082 (82403000)|USER_DEBUG|[34]|DEBUG|stringID Value: null 17:56:00.082 (82410000)|SYSTEM_METHOD_EXIT|[34]|System.debug(ANY)
If i dont use the parameter, and hard code an ID of an account, it works fine and the grid reloads perfectly. Am i doing something wrong? What am I missing here, why is the parameter not being passed properly?
Any help would be hugely appreciated.
Chris
I would need to see the relevant vf code
Here the VF for the main page
It looks like you are assigning the value to a variable called stringID.
You need to have a setter in your controller called stringId to accept the value. I do not think it will write a url variable called acc in this case. I am not sure when the param will write a url variable and when it will not.
Try creating a getter / setter called stringID and see if that works.
Sorry, I know I didnt post full code. but there is a setter for stringID
Something interesting that I did find playing around this morning was that if I add return false to the oncomplete for the action function, the parameter is being passed, but the page does nothing, and the grid doesnt reload.
So, right now without the 'return false', the parameters arent being passed, but the grid will reload with a hardcoded ID. If i add the 'return false', the parameters are passed correctly, but the grid doesnt reload, nothing happens.
I'm Stumped
how about adding the rerender attribute to the action function.
Tried that as well.....nothing
can you use the oncomplete of the actionfunction instead? or just try return false in the oncomplete of the action function.
I am using the oncomplete of the actionfunction. i have tried return false in the oncomplete of tha action function and within the jquery function itself.
My only suggestions left are to replace divs with apex:outputpanels and rerender those id's as well.
Of course the most basic suggestion is to see if you are getting a javascript error using firebug.
Used Firebug...got an error on the html select when changed...