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

Avoid Postback in Radgrid grouping

5 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ali Akbar
Top achievements
Rank 1
Ali Akbar asked on 05 Aug 2009, 09:26 AM
Scenario: I am performing multi level grouping using radgrid and when i click the expand icon it makes a postback. i wanted to avoid postback it should render content n when expand/collapse should not make a postback.

below is the code.
 
protected void Page_Init(object sender, EventArgs e)  
    {  
        RadGrid radGrid1 = new RadGrid();  
        radGrid1.ID = "radGrid1";  
        radGrid1.Skin = "Outlook";  
 
        radGrid1.DataSourceID = "SqlDataSource1";  
        radGrid1.GridLines = GridLines.None;  
 
        radGrid1.MasterTableView.GroupsDefaultExpanded = false;  
 
        GridGroupByExpression expression = new GridGroupByExpression();  
        GridGroupByField gridGroupByField = new GridGroupByField();  
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "name";  
        gridGroupByField.HeaderText = "Name";  
        expression.SelectFields.Add(gridGroupByField);  
 
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "name";  
        gridGroupByField.HeaderText = "Name";  
        expression.GroupByFields.Add(gridGroupByField);  
 
        GridGroupByExpression expression1 = new GridGroupByExpression();  
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "Category";  
        gridGroupByField.HeaderText = "Category";  
        expression1.SelectFields.Add(gridGroupByField);  
 
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "Category";  
        gridGroupByField.HeaderText = "Category";  
        expression1.GroupByFields.Add(gridGroupByField);  
        radGrid1.MasterTableView.GroupByExpressions.Add(expression);  
        radGrid1.MasterTableView.GroupByExpressions.Add(expression1);  
        this.PlaceHolder1.Controls.Add(radGrid1);  
 
 
    }  


Thanks a million...

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 05 Aug 2009, 09:49 AM
Hello Ali,

You can set the GroupLoadMode of the grid to Client, inorder to avoid postback:

c#:
radGrid1.MasterTableView.GroupLoadMode = GridGroupLoadMode.Client;

Thanks
Princy.


0
Ali Akbar
Top achievements
Rank 1
answered on 05 Aug 2009, 10:04 AM
Thanks princy.

But when i tried to expand the outer group the inner group is by default expanding. When i expand the outer group the inner group should be in collapse mode, how do i do it?


Thanks a million in advance.
0
Princy
Top achievements
Rank 1
answered on 05 Aug 2009, 11:18 AM
Hello Ali,

Since you do not want to expand your group levels initially, you can ajaxify your grid using the AjaxManager or AjaxPanel to avoid postbacks, instead of setting GroupLoadMode to Client.

Hope this helps..
Princy.
0
Ali Akbar
Top achievements
Rank 1
answered on 05 Aug 2009, 11:33 AM
Princy,

I dont want to ajaxify my grid instead i want every group whichever level it belongs to should be in collapsed mode.

ex: Level 1:Names is by default collapsed but when expanding Name the Level 2: category is coming as expanded this is what i wanted to see collapse too..


Hope you understood .


Thanks a million in advance.
0
Gaurav
Top achievements
Rank 1
answered on 03 Jun 2011, 09:16 AM
Hi
I am creating group name on ItemDataBound.

if (e.Item is GridGroupHeaderItem)
item.DataCell.Controls.Add(htmlControl);

I used the update panel. When I perform another task on page then group name changed with  item.DataCell.Text. Which display like

Item: 000Management1-Management; ItemId: 2263

thanks
Tags
Grid
Asked by
Ali Akbar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Ali Akbar
Top achievements
Rank 1
Gaurav
Top achievements
Rank 1
Share this question
or