This is a migrated thread and some comments may be shown as answers.

Cnanging Pager InfoPart at client side

2 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kristijan
Top achievements
Rank 1
Kristijan asked on 12 Jan 2012, 04:15 PM

Hi,

I am implementing an application using RadGrid, where I am using the following features:

  • Client-side binding
  • Paging mode NextPrevAndNumeric

I have a large amount of data (approximately 50k entries) and I found out that SQL server needs a large amount of data in order to sort all the selected data.

As I support filtering, users will use this option to reach the needed item instead of loading them all and using the pager.

According to these facts my idea is to:

  • Select the top 1000 hits
  • On the pager change the info section "rgInfopart" by using javaScript from
    • “1000 items in 100 pages” to
    • first 1000 items in 100 pages”.

The only problem is, that I cannot find the event late enough to bind the client function that does the needed job. I tried with the “OnDataBound” but on that time the number of available hits is not yet available.

function ModifyPagerInfo() {
    var hitsNo = $('.rgPagerCell .rgInfoPart strong span:first').html();
    if (1000 > hitsNo)
        $('.rgPagerCell .rgInfoPart strong span:first').html('first ' + hitsNo);
}

Does anyone knows if there is any event late enough in order to change the pager info.

Or there is any other possibility to reach the needed functionality?

Thank you,

Kristijan

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 18 Jan 2012, 09:27 AM
Hello Kristijan,

Can you try setting PagerTextFormat property of the grid and let me know if it works for you? Note that the '{4}' parameter is mandatory when setting the property. Also, please elaborate if you use declarative or programmatic client-side binding.

Additionally, I would suggest that you execute the code from OnDataBound event inside setTimeout() method and see if it makes any difference.

I am looking forward for your reply.

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Kristijan
Top achievements
Rank 1
answered on 18 Jan 2012, 11:52 AM

Hi Pavlina,

Thank you for your answer.

I tried to set the PagerTextFormat but there is no change in the text pager text.

Even if it were it would not solve my problem as I have a conditional statement “if(1000 == hitsNo) …”.

Accordingly I implemented the other suggestion with (setTimeout() method), which I already considered as an alternative. 
Actually I used the setInterval() method: 

var __pagerIntervalId;
var __pagerChangeTries;

function
rgvMainDataBound(sender, args) {
    __pagerIntervalId = setInterval(modifyPagerInfo, 100);
    __pagerChangeTries = 0;
}
 
function modifyPagerInfo() {
    var hitsNo = $('.rgPagerCell .rgInfoPart strong span:first').html();
    if (1000 == hitsNo) {
        $('.rgPagerCell .rgInfoPart strong span:first').html('First ' + hitsNo);
        clearInterval(__pagerIntervalId);
    }
    else if (__pagerChangeTries == 20) {
        clearInterval(__pagerIntervalId);
    }
    else
        __pagerChangeTries++;
}

Thank you again, 
Kristijan

Tags
Grid
Asked by
Kristijan
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Kristijan
Top achievements
Rank 1
Share this question
or