views:

280

answers:

1

Is there a way of set some "PageSize" property according the number of "Group Headers" in a RadGrid?

Regards!

The code snippet is bellow:

    protected void PageResults(DataTable AnyDataTable) {

//Textbox where user inserts the number of registers that will be showed per page.

if (txt_register_per_page.Value.HasValue) 
{
    int RegistersPerPage = 0, EveryItens = 0;                
    string OldData = "";

    //The loop runs over all the table's rows.
    for (int Index = 0; Index <= AnyDataTable.Rows.Count; Index++)
    {                    
        //The "ColumName" is the one that all the others will be grouped.
        //If no matches with the current data, means that is another "group".
        if (!(String.Equals(AnyDataTable.Rows[Index]["ColumnName"].ToString(), OldData)))
        {                        
            RegistersPerPage++;
            if (RegistersPerPage == txt_register_per_page.Value)
            {
                EveryItens = Index;
                break;
            }

            OldData = AnyDataTable.Rows[Index]["ColumnName"].ToString();
        }
    }
    MyRadGrid.PageSize = EveryItens;
} 

}

As I see, the PageSize property allows the grid to show pages based in ALL the registers, then I tried to begin writing something that converts the total data for the respective number of groups that the user inputs on the textbox.

A: 

Hey,

There is a pagesize property, but it doesn't take into affect the row type to do some specialized function. You'd have to examine the data (and do the grouping yourself) and manually calculate the groups... I don't know if that is an efficient solution.

What type of grouping calculation do you want to do?

Brian
Agreed. You will have to analyze the data before binding because when the data is grouped, it's already rendered. It would be too late to set the PageSize property.
asp316
Well, before asking here, I've made a code that actually made it what I want, but it works only in the first page... I think my logic wasn't far enought, or maybe I don't know so much about Telerik or .Net framework. I'll edit my question to put a code snippet... maybe it helps. =)
Kira
Well, I assume the pagesize changes per the different result set sizes? So you'd be changing it every time you page through the grid, which always requires a rebinding?
Brian