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

[Solved] data grouped just for current page

3 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mojtaba
Top achievements
Rank 1
Mojtaba asked on 26 Aug 2009, 09:59 AM
I am using need_datasource function to bind my grid:

void grdFinancialPeriods_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    { 
        BindGrid(); 
    } 
private void BindGrid() 
    { 
        int count = 0; 
 
        FinancialPeriodManagerClient service = new FinancialPeriodManagerClient(); 
        grdFinancialPeriods.MasterTableView.FilterExpression = string.Empty; 
        Prd[] list = service.GetAllFinancialPeriods(out count, grdFinancialPeriods.PageSize, 
            grdFinancialPeriods.MasterTableView.CurrentPageIndex * grdFinancialPeriods.PageSize, 
           (Behsaman.FilterItemList)Session["filterItemList"], 
           (SortItem)Session["SortExpression"]); 
 
        grdFinancialPeriods.DataSource = list; 
        grdFinancialPeriods.VirtualItemCount = count; 
        grdFinancialPeriods.DataBind(); 
        service.Close(); 
         
    } 

and service function is :

public List<Prd> GetAllFinancialPeriods(int maximumRows, int startRowIndex, 
            FilterItemList filterItemList, SortItem sortItem, out int count) 
        { 
            var query = (from prd in Generals.Db.Prds 
                         select prd); 
 
            query = GetFilterQuery(query, filterItemList); 
            query = GetSortQuery(query, sortItem); 
            count = query.Count(); 
            return query.Skip(startRowIndex).Take(maximumRows).ToList().Deserialize<Prd>(); 
        } 


when I group a column just current page grouped, How can I group all data?

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 28 Aug 2009, 09:22 AM
Hi Mojtaba,

When you group the grid's data by a certain column, the whole data will be grouped, not just the records in the current page. However, only the number of items specified by the page size property will be displayed on the current page.

You can take a look at our online examples on RadGrid's grouping where the point I have made above is demonstrated:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/expressions/defaultcs.aspx

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mojtaba
Top achievements
Rank 1
answered on 30 Aug 2009, 05:52 AM
Hi Tsvetoslav,

In my case(read code please) just current page grouped. It is natural because I am using Skip and Take functions. for resolve this problem I passed additional parameter that contains group expression, and manually group items before call Skip and Take functions.
Is there any better solution?

Thanks.
0
Tsvetoslav
Telerik team
answered on 02 Sep 2009, 02:08 PM
Hi Mojtaba,

I'd like first to turn your attention to the NeedDataSource event of the grid. You should not be calling the control's DataBind() method in the NeedDataSource event as it will be automatically called by RadGrid's internal code. As for the group-by expressions - this is the correct way to achieve grouping in code behind.

The posted code does not give any signs of grouping being enforced on the grid.

I hope this helps.

All the best,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Mojtaba
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Mojtaba
Top achievements
Rank 1
Share this question
or