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

Top x Rows functionality

3 Answers 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 18 May 2010, 02:15 PM
Hi All,

As part of a process of optimizing my grids I want to include a drop down combobox on the page and ideally to conserve space it will be in the pager section.  I intend on providing a MaxRows parameter to my Stored Procedure that will then use SET ROWCOUNT @MaxRows to limit the number of rows returned.  To that end I need a combo box to show a variety of options for the rowcount. 

All easy enough until I need to add the combo box to the pager.  I am using the standard pager except for the fact that I'm inserting some custom numbers into the results per page dropdown.  Is there a simple way to extend the pager or will I be stuck having to use a pager template?

If I have to use the pager template, is there an example somewhere of how to duplicate the normal style?

Regards,

Jon

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 May 2010, 02:32 PM
Hello Jon,

Have you tried the PagerStyle -> Mode ="NextPrevAndNumeric" which already has a PageSize combobox to select the pages.
Also he following forum shows how to customize the options in pageSize combo:
Custom paging items

If you want to add an extra combo control in pagerItem, then you can add from code behind in the ItemCreated event.
C#:
 
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        if (e.Item is GridPagerItem)  
        {  
            RadComboBox combo = new RadComboBox(); // Create new combo  
 
            GridPagerItem pagerItem = (GridPagerItem)e.Item;  
            pagerItem.Cells[0].Controls.Add(combo);     
        }  
    } 


Thanks,
Princy.
0
Jon
Top achievements
Rank 1
answered on 18 May 2010, 03:06 PM
Hi Princy,

Many thanks for that - I already had the custom paging on my page but the second bit of code was very useful.  I did think of trying that kind of thing but for some reason thought it wouldn't work - I'm now pleased that I was wrong ;)

Now to get the pager on one line, text and combo properly aligned, working with a post back etc ;)

Regards,

Jon
0
Jon
Top achievements
Rank 1
answered on 19 May 2010, 09:42 AM
Arghh!

This was all working great.  I now have the problem that because the grid sorts independantly of the database the results that get returned by the database are not what should be returned.

Does anyone know a way to pass the sort order fields to a Stored procedure and have SQL use those fields in the Order By clause?

Ie

grid sorted on DateReceived column

SELECT returns data that is currently unsorted but needs to be on the DateReceived column.

When the grid sort order is changed then a different DB column needs to be used.

This would I suppose be easy enough if I wasn't using stored procs...

Cheers,

Jon
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jon
Top achievements
Rank 1
Share this question
or