Regarding grouping in column with dropdownlist

6 posts, 0 answers
  1. shweta
    shweta avatar
    6 posts
    Member since:
    Feb 2014

    Posted 24 Feb 2014 Link to this post

    Hi,

    PFA

    it is possible to perform sorting,flitring and grouping on the column which has drop down list inside it.

    please reply asap.


    thanks.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Feb 2014 in reply to shweta Link to this post

    Hi Shweta,

    RadDropDownList only supports Sorting of an items in the list as follows. As a suggestion you can use RadComboBox, which supports Sorting,Filtering and Grouping. Please have a look into the sample code snippet. 

    ASPX:
    <telerik:RadDropDownList ID="RadDropDownList1" runat="server">
        <Items>
            <telerik:DropDownListItem Text="Swedish Cars" />
            <telerik:DropDownListItem Text="Volvo" />
            <telerik:DropDownListItem Text="Saab" />
            <telerik:DropDownListItem Text="German Cars" />
            <telerik:DropDownListItem Text="Mercedes" />
            <telerik:DropDownListItem Text="Audi" />
        </Items>
    </telerik:RadDropDownList>
    <telerik:RadComboBox ID="RadComboBox1" runat="server" Skin="Vista" Width="150px" Filter="Contains" AllowCustomText="true">
        <Items>
            <telerik:RadComboBoxItem runat="server" IsSeparator="True" Text="Swedish Cars" />
            <telerik:RadComboBoxItem runat="server" Text="Volvo" />
            <telerik:RadComboBoxItem runat="server" Text="Saab" />
            <telerik:RadComboBoxItem runat="server" IsSeparator="True" Text="German Cars" />
            <telerik:RadComboBoxItem runat="server" Text="Mercedes" />
            <telerik:RadComboBoxItem runat="server" Text="Audi" />
        </Items>
    </telerik:RadComboBox>

    C#:
    RadDropDownList1.Items.Sort();
    RadComboBox1.Items.Sort();

    Please take a look into the following help documentations.

    Sorting
    Filtering
    Grouping

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shweta
    shweta avatar
    6 posts
    Member since:
    Feb 2014

    Posted 24 Feb 2014 in reply to Princy Link to this post

    Hi Princy,
    i used below code. please check once.
    <Columns>
                                                        <telerik:GridBoundColumn DataField="ContentTitleId" HeaderText="ID" UniqueName="ID" FilterControlWidth="140px">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn DataField="ContentTitleName" HeaderText="Content Title" FilterControlWidth="140px">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridTemplateColumn HeaderText="8125 Setup" UniqueName="DropdownColumn" FilterControlWidth="140px">
                                                            <ItemTemplate>
                                                                <telerik:RadComboBox ID="dropDownListInGrid" runat="server" EnableItemCaching="True"
                                                                    EnableTextSelection="False" AppendDataBoundItems="True" DataTextField="Flag8125Description"
                                                                    DataValueField="Flag8125ID" ShowDropDownOnTextboxClick="False" Skin="Office2007">
                                                                    <Items>
                                                                        <telerik:RadComboBoxItem runat="server" Text="Select One" Value="0" />
                                                                    </Items>
                                                                </telerik:RadComboBox>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn HeaderText="eInduction" UniqueName="EInductionFlag" FilterControlWidth="140px">
                                                            <ItemTemplate>
                                                                <telerik:RadComboBox ID="rcbGridEInductionFlag" runat="server" EnableItemCaching="True"
                                                                    EnableTextSelection="False" AppendDataBoundItems="True" DataTextField="EInductionDescription"
                                                                    DataValueField="EInduction" ShowDropDownOnTextboxClick="False" Skin="Office2007" Width="40">
                                                                    <Items>
                                                                        <telerik:RadComboBoxItem runat="server" Text="No" Value="0" />
                                                                    </Items>
                                                                </telerik:RadComboBox>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                    </Columns>
                                                </MasterTableView>
                                                <ClientSettings AllowColumnsReorder="true" AllowDragToGroup="true" AllowGroupExpandCollapse="true" ReorderColumnsOnClient="true">
    Now i am able to do sorting ,filtering and grouping on first two column. but for last two column how i have to do.

    please check and let me know asap.


    Thanks.
    shweta 
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Feb 2014 in reply to shweta Link to this post

    Hi shweta,

    Please try the following code snippet which works fine at my end.

    ASPX:
    ...                  
     <telerik:GridTemplateColumn HeaderText="8125 Setup" UniqueName="DropdownColumn" FilterControlWidth="140px" DataField="FirstName">
       <ItemTemplate>
           <telerik:RadComboBox ID="dropDownListInGrid" EnableTextSelection="true" AppendDataBoundItems="false" ShowDropDownOnTextboxClick="false" Skin="Office2007" runat="server" Filter="Contains" EmptyMessage="Select One" DataTextField="FirstName" Sort="Ascending" OnItemDataBound="dropDownListInGrid_ItemDataBound">
           </telerik:RadComboBox>
       </ItemTemplate>
     </telerik:GridTemplateColumn>
    ...

    C#:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        foreach (GridDataItem item in RadGrid1.Items)
        {
            RadComboBox combo1 = (RadComboBox)item.FindControl("dropDownListInGrid");
            combo1.DataSourceID = "SqlDataSource1";
        }
    }
    protected void dropDownListInGrid_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
    {
        foreach (GridDataItem item in RadGrid1.Items)
        {
            RadComboBox combo1 = (RadComboBox)item.FindControl("dropDownListInGrid");
            combo1.Items.Sort();
        }
    }

    Thanks,
    Princy.
  6. shweta
    shweta avatar
    6 posts
    Member since:
    Feb 2014

    Posted 26 Feb 2014 in reply to Princy Link to this post

    Hi Princy,

    i used sort expression with template column and
    GroupByExpression,
    Groupable so now i am able to do sorting and grouping...but filtering m not getting how to do it? and after grouping of column when m trying to put it back it is showing some exception.

    can u send me the code for filtering..if possible today only..

    thanks.
    shweta
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Feb 2014 in reply to shweta Link to this post

    Hi Shweta,

    I guess you want to perform sorting, filtering and grouping on the RadGrid TemplateColumns. To perform sort on a GridTemplateColumn we have to set SortExpression, for grouping GroupByExpression should be set and for filtering, AllowFiltering property and DataField of the column should be set. Please take a look at the below code snippet:

    ASPX:
    <telerik:GridTemplateColumn HeaderText="ShipCity" UniqueName="ShipCity" FilterControlWidth="140px" AllowFiltering="true" DataField="ShipCity" SortExpression="ShipCity" GroupByExpression="ShipCity Group By ShipCity">
        <ItemTemplate>
            <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource2" DataTextField="ShipCity" DataValueField="OrderID" AppendDataBoundItems="true">
                <Items>
                    <telerik:RadComboBoxItem runat="server" Text="Select One" Value="0" />
                </Items>
            </telerik:RadComboBox>
        </ItemTemplate>
    </telerik:GridTemplateColumn>

    Thanks,
    Princy
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017