In my previous post about “javascript remoting using jquery tempaltes”, we saw how we use remoting to easily render a salesforce style grid of accounts.
In this post, we will see how we can easily extend the same account grid example, to finally have following features
- A account search box, that allows user to search for accounts via name. (this search is powered by Javascript Remoting)
- Account records returned by Javascript remoting search are rendered into a salesforce style pageblocktable, this is done using jquery templates.
- Have editable PHONE field in the account grid. When user changes any phone number in this grid its updated back on the account record in salesforce (this update is powered by Javascript Remoting)
Where is the code ?
Code for both Apex Controller and Visualforce page is available on snipplr.com. If you have any comments/concerns/queries please comment back here on this post.Remoting in Action !
Searching for accounts

Account updated on blur

So, Javascript Remoting == ViewStateLess VisualForce ?
It would be great if we can go 100% view stateless !!! but as of now, its not 100% possible to go view stateless on all fronts using Javascript Remoting.The major reason I see is “locale specific formatting and validations”. These validations are done super smartly and silently by visualforce tags like <apex:inputField …/>. So, you have to be careful, if you are going to deal with fields like Number, Currency and Date fields in visualforce.
But, that doesn't means we loose heart and can't do cool things, with HTML 5 "input" tag has gone much smarter then ever before i.e. supporting phone, email etc as type.
12 comments:
If only Javascript Remoting supported Collections and sObjects or even just Objects, instead of only primitive datatypes :(
I don't expect to see that in Summer '11... maybe Winter?
Hey Ryan,
Good News, Remoting supports Primitive/Sobject collections, please check this link : http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm#pages_js_remoting
Though nicer would be to have support for User defined Apex classes, that will allow encapsulation/aggregation of more information in one call.
Nice post. Just wanted to let you know that support for user defined Apex classes is coming in Summer '11...
Hey Stephan ! Thats really exciting news, thanks for sharing :)
Very good and useful post.
got stumped by the limitation though (not supporting custom Apex types :(.. ). something is eating up all of my view state, so thought of going with Remoting. seems like i have to wait for a few months...
Thanks Mohammad Swaleh, glad you liked the post.
yeah custom apex types would be great addition to the remoting stack, I am also waiting for it to release !
Abhinav,
My inquiry as it relates to SObject/Collections was geared at the RemoteAction parameters...
The ability to return SObjects and collections is great, but it would be nice to be able to pass in a Primitive Array for instance without having to .join(',') in javascript and .split(',') in apex to get a list...
Ryan, thats a very good point and a genuine requirements. We should post this as an idea for enhancing the remoting api.
Thank you for sharing this solution, this problem has been bothering me for some time now.
us vpn
I'm glad @Timmy that this solution helped !
Hi Abhinav,
Is there any way to send sObject, and collections as input parameter.
So far I have only sent stringified json, and parsed it back .
Though the URL says its possible i could not locate any examples.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm#pages_js_remoting
Regards
Dipankar@arxxus.com
Hi Dipul, Apex REST web services allow this, so same should hopefully apply here.
Post a Comment