You need to sign in to do that
Don't have an account?
Sean_k
Ajax - Pagination
I am developing a Ajax scontrol(Report) where I show next 100/50/25 days Events.Customer is asking for pagination as there are thousands of events.
Could some body please provide guidelines or samples for the best practices to use.
Could some body please provide guidelines or samples for the best practices to use.
Thanks,
Sean
Sean
First of all i am guessing that right now you get all the data, events for the next 100/50/25 days and display it on the page. I just have a quick question, how much time does it take to get this much data? there are two ways to do the paging for this data. if the time to get the data from sales-force is less, say 5 to 10 sec, then you can use client side paging. to do this you can use an open source free table data paging library from here http://www.javascripttoolbox.com/lib/table/ it is very simple and you can very easily implement it. The second way is that you use the sales-force's querymore function. when you first query for the events use a limit, say 50. Once you get these 50 records, you can display these 50 records in the HTML table using the javascript and it is very easy. One more thing that you should do is to store these 50 records in a javascript array so you can use them later on. then you can create a couple of links at the end of the table to go forward or backward. create a function to querymore from sales-force for the events and get next 50 event records. store these 50 in the array and then clear the table by removing the rows and then display these records there. this way you can create forward paging. to go back you just have to use the javascript array you used to store the extracted event records. just traverse the array like any other array and get the number of records from the array and then clear the table and display the records there.
IF you need more detail please let me know.
I am also looking to develop same functionality. Thanks fot the link on javascripttoolbox. If you have , could you please provide some working examples with relates to salesforce.com as well ?
Regards
Pramod
have a close look at the HTML portion of the code where i have defined a table and other html elements and then i have setup the class names for these elements. you can read about the table paging from the above link in more detail. you can change the css in the page to change the table layout.
Let me know if you have any other question.
Thanks for your quick response. I will get back to you soon with results.
Regards
Pramod
Your logic works beautifully for the first search result. However I am creating table based on the custom search criteria. so when user searches second time , rows gets appended to the first search result. To clear first result, I must use mtblBody.innerHTML = " " . (mtblBody is tbody object instance) This works on Firefox but in case of IE tbody.innerHTML is READONLY . (innerHTMLproperties from Microsoft)
How do I clear tbody so that every time user searches , tbody is created as new object rather then appending rows ?
Code:Any suggestions how to get around this? (Code attached below)
Thanks for your help.
Pramod
One way to clear the table is to assign a unique Id to each of the row you insert dynamically. like
Row.Id = "rowId" + i ;
and then when you want to clear the table, just delete these rows by selecting them with their Ids and removing the seleted element from the table.
function removeTbodyRow(rowid)// like 'rowId0'
{
var deletedRow = document.getElementById(rowid); // Selecting the Row element to be deleted
document.getElementById('tableId').deleteRow(deletedRow.rowIndex);
}
modify the above function and use it to remove all the rows in the table. let me know what happen.
This is what worked ..
function clearTable(tbody)
{
while (tbody.rows.length > 0)
{
tbody.deleteRow(0);
}
}
Thanks for your excellent help. I am able to create pagination the way I wanted :smileyvery-happy:
Best Regards
Pramod