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

Setting up filter in grid

1 Answer 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 2
Robert asked on 26 Mar 2013, 03:34 PM
I am a newbie to c# and the telerik controls and would appreciate some help.  I have created a grid, populated it (banded it) and it work perfect. Now I need to set up filters. A few of the filters are RadCombo that I would like to bind. The following is code for my aspx for the grid. "colEquipmentType" is the column that I would like a filter. As you can see in the attached image I am able to get the control in the column. The largest issue that I am having is binding in my .cs file. 

Thanks for any help you can give me.


 <%--Grid--%>
            <td class="grid" rowspan="9">
                <telerik:RadGrid runat="server" ID="rgEquipmentRecords" CellSpacing="0" Skin="Vista"
                    Width="98%" AutoGenerateColumns="False" GridLines="None" AllowSorting="True"
                    OnNeedDataSource="rgEquipmentRecords_NeedDataSource" AllowPaging="True" GroupingEnabled="False"
                    OnItemCommand="rgEquipmentRecords_ItemCommand" AllowFilteringByColumn="True">
                    <AlternatingItemStyle BackColor="AliceBlue" />
                    <ItemStyle BackColor="White" />
                    <PagerStyle Mode="NextPrev" AlwaysVisible="True" ShowPagerText="False" />
                    <MasterTableView DataKeyNames="EquipmentType,Qty,IssuedTo,DateIssued,Approvedby,IssuedBy,ID,Notes"
                        PageSize="13">
                        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Visible="True">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>
                        <Columns>
                            <%--Grid Column Record Id--%>
                            <telerik:GridBoundColumn DataField="ID" HeaderText="Rec ID" ReadOnly="true" UniqueName="colID"
                                ItemStyle-HorizontalAlign="center" AllowFiltering="False">
                                <HeaderStyle HorizontalAlign="Center" Width="60px" />
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>


                            <%--Grid Column Equipment Type--%>
                            <telerik:GridBoundColumn DataField="EquipmentType" HeaderText="Equip Type" ReadOnly="true"
                                UniqueName="colEquipmentType" ItemStyle-HorizontalAlign="Left">
                                <HeaderStyle Width="90px" />
                                <ItemStyle HorizontalAlign="Left"></ItemStyle>
                                <FilterTemplate>
                                    <telerik:RadComboBox ID="cboEquipmentTypeFilter" DataTextField="DESC"
                                    DataValueField="ID" Height="200px" AppendDataBoundItems="true" 
                                        runat="server" >
                                        <Items>
                                            <telerik:RadComboBoxItem Text="All" />
                                        </Items>
                                    </telerik:RadComboBox>
                                </FilterTemplate>
                            </telerik:GridBoundColumn>


                            <%--Grid Column QTY--%>
                            <telerik:GridBoundColumn DataField="Qty" HeaderText="QTY" ReadOnly="true" UniqueName="colQty"
                                ItemStyle-HorizontalAlign="Center" AllowFiltering="False">
                                <HeaderStyle HorizontalAlign="Center" Width="60px" />
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <%--Grid Column BarCode Number--%>
                            <telerik:GridBoundColumn DataField="BarcodeNumber" HeaderText="Barcode" ReadOnly="true"
                                UniqueName="colBarcode" ItemStyle-HorizontalAlign="Center">
                                <HeaderStyle HorizontalAlign="Center" Width="60px" />
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <%--Grid Column Dept/Div/Emp Issued--%>
                            <telerik:GridBoundColumn DataField="IssuedTo" HeaderText="Dept/Div/Emp Issued" ReadOnly="true"
                                UniqueName="colDeptDivEmpIssue" AllowFiltering="False">
                                <HeaderStyle Width="200px" />
                            </telerik:GridBoundColumn>
                            <%--Grid Column Date Issue--%>
                            <telerik:GridBoundColumn DataField="DateIssued" HeaderText="Date Issue" ReadOnly="true"
                                UniqueName="colDateIssue">
                                <HeaderStyle Width="110px" />
                            </telerik:GridBoundColumn>
                            <%--Grid Column Approved By--%>
                            <telerik:GridBoundColumn DataField="Approvedby" HeaderText="Approved By" ReadOnly="true"
                                UniqueName="colApprovedby">
                                <HeaderStyle Width="150px" />
                            </telerik:GridBoundColumn>
                            <%--Grid Column Issued By--%>
                            <telerik:GridBoundColumn DataField="IssuedBy" HeaderText="Issued By" ReadOnly="true"
                                UniqueName="colIssuedBy">
                                <HeaderStyle Width="150px" />
                            </telerik:GridBoundColumn>
                            <%--Grid Column Notes--%>
                            <telerik:GridBoundColumn DataField="Notes" HeaderText="Notes" ReadOnly="true" UniqueName="colNotes"
                                AllowFiltering="False">
                                <HeaderStyle Width="150px" />
                            </telerik:GridBoundColumn>
                            <%--Grid Column Delete--%>
                            <telerik:GridButtonColumn UniqueName="colDelete" HeaderText="Delete" ButtonType="ImageButton"
                                ItemStyle-HorizontalAlign="center" ConfirmText="This action will delete the selected record, are you sure?"
                                ConfirmDialogType="RadWindow" CommandName="Delete" ImageUrl="~/Images/Icons/DeleteRed.png">
                                <HeaderStyle Width="70px" />
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridButtonColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                        <PagerStyle Mode="NextPrev" />
                        <HeaderStyle Font-Bold="true" Font-Size="Small" Height="10px" />
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2013, 04:45 AM
Hi,

Try the following code.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
        if (e.Item is GridFilteringItem)
        {
            GridFilteringItem item = (GridFilteringItem)e.Item;
            RadComboBox cmb = (RadComboBox)item.FindControl("RadComboBox1");
            //populate combobox
        }
}
Also check the following demo.
Grid - Filter Templates

Thanks,
Shinu
Tags
Grid
Asked by
Robert
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or