You need to sign in to do that
Don't have an account?
ckellie
How to create Button to Sort Related Items
I am trying to create a Javascript button to custom sort Quote Line Items by a custom field. All I have is:
doSort({!QuoteLineItem.Quote_Item_Number__c}, asc)
I have been trying to find an example of how to do this, but have come up short. Can anyone point me to an example or how to write a button from Javascript?
What is another way to achieve the same result?
Thank you
Hi,
I guess it depends on what it is you want to achieve and in what context.
If you're looking to add a custom button to a standard page and have that sort quote line items I'm not sure that can be done. My approach would be to either:
Example of sorting data:
The example above is somewhat prepared for my 2nd suggestion. Assuming your VF Page has an input field and a button which is linked to your controller, you could, in your controller, set the order variable based on the users input, then fetching data again but now ordered by the user's input.
Finally, if you don't want to have users stress the system with quering the database all the time you could fetch the data once (assuming a default sort based on a field on the User object/profile/role) and then keep data in your controller and simply sorting data in memory based on the user's input (without quering the backend).
Hope it helps.
/Søren Nødskov Hansen
All Answers
Hi,
I guess it depends on what it is you want to achieve and in what context.
If you're looking to add a custom button to a standard page and have that sort quote line items I'm not sure that can be done. My approach would be to either:
Example of sorting data:
The example above is somewhat prepared for my 2nd suggestion. Assuming your VF Page has an input field and a button which is linked to your controller, you could, in your controller, set the order variable based on the users input, then fetching data again but now ordered by the user's input.
Finally, if you don't want to have users stress the system with quering the database all the time you could fetch the data once (assuming a default sort based on a field on the User object/profile/role) and then keep data in your controller and simply sorting data in memory based on the user's input (without quering the backend).
Hope it helps.
/Søren Nødskov Hansen
I think I will use the second choice you wrote. Thank you