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

Regarding grouping in column with dropdownlist

5 Answers 112 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
shweta
Top achievements
Rank 1
shweta asked on 24 Feb 2014, 12:58 PM
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.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Feb 2014, 04:34 AM
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.
0
shweta
Top achievements
Rank 1
answered on 25 Feb 2014, 04:53 AM
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 
0
Princy
Top achievements
Rank 2
answered on 26 Feb 2014, 05:46 AM
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.
0
shweta
Top achievements
Rank 1
answered on 26 Feb 2014, 07:07 AM
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
0
Princy
Top achievements
Rank 2
answered on 27 Feb 2014, 05:18 AM
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
Tags
DropDownList
Asked by
shweta
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
shweta
Top achievements
Rank 1
Share this question
or