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

How to add a footer row?

1 Answer 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chris lively
Top achievements
Rank 1
chris lively asked on 28 Sep 2010, 07:46 PM
I have a radgrid with the following definition
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="True"
            AllowMultiRowEdit="True"
            GridLines="None" Skin="Web20" OnPreRender="RadGrid1_PreRender"
            OnItemCommand="RadGrid1_ItemCommand"
            OnCreateColumnEditor="RadGrid1_CreateColumnEditor"

            >
        <MasterTableView EditMode="InPlace" CommandItemDisplay="Bottom">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>

            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn ConvertEmptyStringToNull="False" DataField="Name"
                    HeaderText="Name Column" MaxLength="50" ReadOnly="True" UniqueName="NameColumn">
                </telerik:GridBoundColumn>
            </Columns>
            <CommandItemTemplate>
                <asp:Button runat="server" Text="Save All" ID="SaveButton" visible="true" CommandName="UpdateAll" />
            </CommandItemTemplate>
        </MasterTableView>
        </telerik:RadGrid>


Most of the columns come from a databound source.  I need to add an additional row where there is a single checkbox for each column. For example (forgive the ascii art):
--------------------------------------------------------------------------
|Name Column |Col 1              | Col 2             | Col 3             |
--------------------------------------------------------------------------
|Some Name    | <drop down> | <drop down> | <drop down>|
--------------------------------------------------------------------------
|Another Name | <drop down> | <drop down> |<drop down> |
--------------------------------------------------------------------------
| Check These | <checkbox>   | <checkbox>   | <checkbox> |
--------------------------------------------------------------------------
|<submit button>                                                                  |
--------------------------------------------------------------------------

I have it creating all of the drop down lists in the CreateColumnEditor event. Also, all of the rows (except the checkbox one) come from the datasource.

How can I add footer row that contains those checkboxes?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Sep 2010, 07:04 AM
Hello Chris,
 In itemCreated event loop through each column and add Checkbox for each column's footer. Sample code is given below.

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridFooterItem)
        {
            GridFooterItem fitem=(GridFooterItem) e.Item;
            foreach(GridColumn column in RadGrid1.MasterTableView.AutoGeneratedColumns)
            {
                CheckBox chkbx = new CheckBox();
                fitem[column.UniqueName].Controls.Add(chkbx);
            }
        }
    }

Note: set ShowFooter of RadGrid as 'true' .

Regards,
Shinu.
Tags
Grid
Asked by
chris lively
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or