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

Combobox Column Clearselection

9 Answers 145 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 10 Nov 2009, 08:30 PM
Does the combobox column support the clearselection button that the radcombobox has?

9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 11 Nov 2009, 02:43 PM
Hello Scott ,

Unfortunately the GridVIewComboBoxColumn does not support  this functionality. It is intended for more general cases and when a specific requirement about the ComboBox editor occurs there is another approach needed  - redefine the CellEditTemplate of the column thus placing your editor with all the settings and additional logic.

Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Scott Rakestraw
Top achievements
Rank 1
answered on 12 Nov 2009, 09:07 PM
I have created a custom combo column to handle the clear selection, virtualized items and custom itemtemplates.  This is working great except for one problem which is that with the VirtualizingStackPanel when I go to the cell it does not automatically browse to the selected item.

Imports Telerik.Windows.Controls 
Imports System.Windows.Data 
Imports System.Windows 
Imports System.Collections 
Imports System.Windows.Markup 
 
Public Class GridViewCustomComboBoxColumn 
    Inherits GridViewComboBoxColumn 
 
    Private _ItemTemplate As DataTemplate 
 
    Public Property ItemTemplate() As DataTemplate 
        Get 
            Return _ItemTemplate 
        End Get 
        Set(ByVal Value As DataTemplate) 
            _ItemTemplate = Value 
        End Set 
    End Property 
 
    Public Overrides Function CreateCellElement(ByVal cell As Telerik.Windows.Controls.GridView.GridViewCell, ByVal dataItem As ObjectAs System.Windows.FrameworkElement 
 
        If ItemTemplate Is Nothing Then 
 
            Return Nothing 
 
        Else 
 
            Dim value As Object = dataItem.GetType.GetProperty(Me.DataMemberBinding.Path.Path).GetValue(dataItem, Nothing
 
            Dim cellTemplate As FrameworkElement = CType(ItemTemplate.LoadContent, FrameworkElement) 
            cellTemplate.DataContext = (From i In ItemsSource _ 
                                        Where i.GetType.GetProperty(SelectedValueMemberPath).GetValue(i, Nothing).Equals(value) _ 
                                        Select i).FirstOrDefault 
            Return cellTemplate 
 
        End If 
 
    End Function 
 
    Public Overrides Function CreateCellEditElement(ByVal cell As Telerik.Windows.Controls.GridView.GridViewCell, ByVal dataItem As ObjectAs System.Windows.FrameworkElement 
 
        Dim cellEditElement As RadComboBox = CType(MyBase.CreateCellEditElement(cell, dataItem), RadComboBox) 
 
        cellEditElement.ClearSelectionButtonVisibility = Windows.Visibility.Visible 
        cellEditElement.ClearSelectionButtonContent = "Clear Selection" 
 
        If Not ItemTemplate Is Nothing Then 
            cellEditElement.DisplayMemberPath = Nothing 
            cellEditElement.ItemTemplate = ItemTemplate 
        End If 
 
        If CType(ItemsSource, IList).Count > 100 Then 
            Dim itemsPanelTemplate As New ItemsPanelTemplate 
            itemsPanelTemplate = CType(XamlReader.Load("<ItemsPanelTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><VirtualizingStackPanel /></ItemsPanelTemplate>"), ItemsPanelTemplate) 
            cellEditElement.ItemsPanel = itemsPanelTemplate 
        End If 
 
        Return cellEditElement 
 
    End Function 
 
End Class 
 

0
Pavel Pavlov
Telerik team
answered on 18 Nov 2009, 03:17 PM
Hi Scott ,
It looks like quite an elegant solution. Can you please paste me the item template XAML. I am pretty sure we can find a solution for the selected value related problem

Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Scott Rakestraw
Top achievements
Rank 1
answered on 18 Nov 2009, 03:26 PM
In the one list that I have that is currently big enough to require the VirtualizingStackPanel it does not have an itemtemplate.  It is just a standard combobox with the VirtualizingStackPanel added.
0
Pavel Pavlov
Telerik team
answered on 20 Nov 2009, 03:21 PM
Hi Scott ,
I have prepared a small project to try reproduce the problem ( please find it attached) .

However I was not able to find any disturbing behavior of the combo with the virtualizing panel. Am I missing something ?

Regards,
Pavel
0
Scott Rakestraw
Top achievements
Rank 1
answered on 20 Nov 2009, 04:44 PM
The sample isn't using the virtualizing panel because it has < 100 records.  Make the following change.

    Private Function GetCountries() As List(Of Country) 
        Dim countries As New List(Of Country)() 
        For x As Integer = 1 To 1000 
            countries.Add(New Country(x, InlineAssignHelper(Name, "Test " + x.ToString))) 
        Next         
        Return countries 
    End Function 

Select a record in the list then leave that cell and go back to it.  The value will still be correct but it will not autoscoll to that selected item in the list and will just show the first few items.
0
Nedyalko Nikolov
Telerik team
answered on 25 Nov 2009, 04:03 PM
Hello Scott Rakestraw,

This issue is fixed with the latest internal build assemblies. I'm attaching the same test application for a reference.

Best wishes,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Louis Bouchard
Top achievements
Rank 1
answered on 25 Apr 2011, 01:36 AM
And now in 2011, it's supported?
0
ham
Top achievements
Rank 1
answered on 25 Apr 2011, 09:55 AM

Hi

This topic help me a lot in developing my project. I will contribute more when I finished it.

If you want to get more materials that related to this topic, you can visit: Project management templates

 

Best regards.

Tags
GridView
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Scott Rakestraw
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Louis Bouchard
Top achievements
Rank 1
ham
Top achievements
Rank 1
Share this question
or