GridViewComboBoxColumn

13 posts, 0 answers
  1. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 24 May 2013 Link to this post

    Hi,

    I want to display a multi-column ComboBox in RadGridView cell. I have followed below blog and I am able to achieve the half of the requirement.
    http://www.telerik.com/help/wpf/radgridview-columns-column-types-combobox-column.html

    However there are some issues:
    1. When I select an item in ComboBox two columns are displayed. Instead of two columns I want to display only one column value when user selected an item and ComboBox collapsed
    2. I want to display Title for these column
    3. And want to allow user to sort

    I also had a look at another blog however here also how to achieve this will GridViewComboBoxColumn and point #1 as mentioned above are not achieved.

    http://blogs.telerik.com/vladimirenchev/posts/10-04-09/how-to-filter-as-you-type-radgridview-inside-radcombobox-for-wpf-and-silverlight.aspx

    Please throw some light on how to achieve this requirement.
  2. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 27 May 2013 Link to this post

    Any suggestion/comment on this Telerik team?
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 May 2013 Link to this post

    Hello,

    As to point 1 and 2: It is not clear what you would like to achieve. Would you please share a picture of what the current view is and what the desired one would be?

    As to point 3. Sorting will work based on the property set for the DataMemberBinding. What is the type of the property you have bound to the GridViewComboBoxColumn?

    Regards,
    Didie
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  4. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 27 May 2013 Link to this post

    Hi Didie,

    PFA image and comment to explain what I am trying to achieve. I hope it would help to understand all three points.

    For point #3 by sort I mean sorting the ComboBox items an not GridView which is already working.  

    As of now I have place Grid inside DataTemplate for GridViewComboBoxColumn but I am planning to place a GridView so that I can display multiple columns as well as I will able to sort it.

    Also if I place GridView in DataTemplate then how to bind ItemsSource to GridViewComboBoxColumn because in this case only one item should be displayed in ComboBox which will be a GridView. 

    However point #1 still not achieve by even in that case.

    Any idea how can I display only currency code (instead of all columns of ComboBox) in GridView currency column Telerik team?

    Thanks.
  5. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 27 May 2013 Link to this post

    Hi Didie,

    Are able to understand the requirement now? Anyone else from Telerik team any comment/suggestion to achieve this requirement?
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 28 May 2013 Link to this post

    Hello,

    The value that will be displayed by default will be the value of the property specified for the DataMemberBinding of the column. If you want to display a single value, then you should bind the column to a property holding this single value.

    You say that you have placed Grid inside DataTemplate for GridViewComboBoxColumn. Do you mean that you have placed it as a CellTemplate? How have you configured it? If you want a single value to be displayed, then why you have defined a Grid? You can leave the default TextBlock displaying the value set as DataMemberBinding?

    For sorting the ComboBox, you should sort the editor of the GridViewComboBoxColumn. The default one is RadComboBox. You can redefine the CellEditTemplate for the column and place inside any editor you prefer. Then handle sorting its items for the editor directly. The column cannot control sorting of its editor.

    Regards,
    Didie
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 28 May 2013 Link to this post

    Hi Didie ,

    Can you please be so kind to have a look at the image I had attached? I tried to explain the requirement in very simple manner.

    I want to display multiple columns in RadComboBox with title and sorting functionality. Hence I placed RadGridView under ControlTemplate of RadComboBox.

    Now since the aforementioned RadComboBox need to be displayed as column in RadGridView. I am using GridViewDataColumn and where I redefined DataTemplate of GridViewDataColumn.CellEditTemplate to display RadComboBox in edit mode (when user double clicks a cell).

    I haven't used GridViewComboBoxColumn since it was not feasible to redefine DataTemplate for the same.

    Now I have also achieved the point #1 which is to display single value in grid when user selects an item from combo.

    There is only one issue which I am struggling with is when I select an item from ComboBox it is not closing as the default behavior of ComboBox.

    To achieve point #1 I have modified ControlTemplate of RadComboBox. To close the RadComboBox I also tried to set IsDropDownOpen property when user click on an item in DataGrid but it's not working.

    To modify RadComboBox ControlTemplate I referred to following blog.
    http://www.nullskull.com/a/1359/wpf-datagrid-as-combobox-dropdown.aspx

    Please let me know if you have any idea how to close the ComboBox when user select an item.

    Thanks.

  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 May 2013 Link to this post

    Hello,

    Would you please check the "ComboBox Column" WPF Demo where the ComboBox is closed after the user selects an item from it? Is this what you would like to achieve?

    Regards,
    Didie
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  9. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 29 May 2013 Link to this post

    Hey Didie,

    Thank for reply.

    I had already look at this demo before posting this question. "ComboBox Column" demo does not satisfy following requirement.

    1. The grid having many other columns with some of them to display ComboBox
    2. ComboBox Column Title is not there (Column titles means ComboBox columns in this case CountryId and Name)
    3. Since title are not there it's not possible to sort items inside ComboBox
    4. When I select an item only Country name should be displayed in grid.

    Is it feasible to achieve aforementioned requirement with either demo you suggested or GridViewComboBoxColumn?

    About closing of ComboBox yes I want same behavior but in ComboBox for which I have modified ControlTemplate to display RadGridView.

    In-case you want code let me know how can I send it to you?
  10. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    Please have a look at image I have attached to understand requirement.
    Hereby attaching updated one where I manage to display column title and sort.
  11. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    Here is the link to modify GridComboBoxItem in WPF control.

    http://www.cnblogs.com/Files/sheva/GridComboBoxDemo.zip

    Please someone guide me to achieve same with Telerik RadGridView.
  12. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 31 May 2013 Link to this post

    Hey Didie,

    Finally I am able to achieve the requirements. However it still needs some improvement. I have bind IsOpen property of Popups inside RadComboBox ControlTemplate to IsDropDownOpen property of RadComboBox which has been set to false on SelectedItem change. And that's it when I click any item in ComboBox it will close the popup.
    I have modified RadComboBox ControlTemplate and replace ScrollViewer and ItemsPresenter with below RadGridView. It's working fine however I want following improvement
    1. In-case there are multiple ComboBoxes I have to create ControlTemplate for each since each ComboBox may have different ItemsSource, No. of columns, DisplayMembers and SelectedValues.
    2. When first time ComboBox display it don't have value selected eventhough it is there in ItemsSource of GridView. Once I select an item from Combo next time onward it displays the value.

    <telerik:RadGridView x:Name="RadGridView99"
        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
        ItemsSource="{TemplateBinding ItemsSource}"
        AutoGenerateColumns="False"
        IsReadOnly="True"
        SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem}"
        ShowGroupPanel="False"
        CanUserFreezeColumns="False"
        RowIndicatorVisibility="Collapsed"
        IsFilteringAllowed="False"
        SelectionMode="Single"
        telerik:StyleManager.Theme="Office_Blue"
        Width="Auto"
        Height="Auto">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="Code"
                DataMemberBinding="{Binding CurrencyISOCode}" />
            <telerik:GridViewDataColumn Header="Name"
                DataMemberBinding="{Binding CurrencyName}" />
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

    Any help will be highly appreciated.
  13. Max
    Max avatar
    27 posts
    Member since:
    May 2013

    Posted 15 Jul 2013 Link to this post

    Hi Didie,

    Finally I decided to move to DevExpress control. They have LookupEdit control which display multiple columns and one can place it inside DataGrid also.

    I wish telerik should also have such control.
Back to Top