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

Sorting Value Converted Template Columns

2 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brian
Top achievements
Rank 1
Brian asked on 04 Jun 2012, 06:21 PM
I have successfully bound a template column with some value conversion. The value converter extracts a value from the raw string to display in the column template.

The problem is - if I sort the grid by this column or any other column the converted value does not change. Basically - the display doesnt change. The underlying value (Raw) does change....

Is there a way to force a refresh of the display in the cell template?

Couple of restrictions - the dataset and its contents are 100% dynamic, I do not know at run time if I'm going to use this column/cell template.

Here is the code behind for my column binding:

Dim sStyleString As String
                    sStyleString = "<Style TargetType=""grid:GridViewCell"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" " & _
                                    "xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" " & _
                                    "xmlns:Results=""clr-namespace:SL.Product.ReportResult;assembly=SL.Product.ReportResult"" " & _
                                    "xmlns:grid=""clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"" >" & _
                                    "<Setter Property=""Template"">" & _
                                    "<Setter.Value>" & _
                                    "<ControlTemplate>" & _
                                    "<Border BorderThickness=""0,0,1,1"" BorderBrush=""#FFD2CFCF"">" & _
                                    "<Results:GridDrillDownButton SourceReportID=""" & ReportID & """ DisplayContent=""{Binding " & repfield.RenamedField & "}"" />" & _
                                    "</Border>" & _
                                    "</ControlTemplate>" & _
                                    "</Setter.Value>" & _
                                    "</Setter>" & _
                                    "</Style>"
                    Dim s1 As System.Windows.Style = DirectCast(System.Windows.Markup.XamlReader.Load(sStyleString), System.Windows.Style)
                    column.SortMemberPath = repfield.RenamedField
                    column.CellStyle = s1


Here is the code behind on GridDrillDownButton

Imports Telerik.Windows.Controls
Imports SL.Product.UIHelper
 
 
Partial Public Class GridDrillDownButton
    Inherits UserControl
    Public DisplayContentProperty As DependencyProperty = DependencyProperty.Register("DisplayContent", GetType(String), GetType(GridDrillDownButton), Nothing)
    Public SourceReportProperty As DependencyProperty = DependencyProperty.Register("SourceReportID", GetType(String), GetType(GridDrillDownButton), Nothing)
 
 
    Private switch As Boolean
    Private oRadWindow As Telerik.Windows.Controls.RadWindow
 
 
    Public Property SourceReportID() As String
        Get
            Return GetValue(SourceReportProperty)
        End Get
        Set(ByVal value As String)
            SetValue(SourceReportProperty, value)
        End Set
    End Property
 
 
    Public Property DisplayContent() As String
        Get
            Return GetValue(DisplayContentProperty)
        End Get
        Set(ByVal value As String)
            SetValue(DisplayContentProperty, value)
        End Set
    End Property
 
 
    Public Sub New()
        InitializeComponent()
    End Sub
 
 
 
 
    Private Sub lnkDisplay_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles lnkDisplay.Click
        Try
            If Not String.IsNullOrEmpty(DisplayContent) Then
                If SourceReportID = "" Then
                    MessageBox.Show("You must save your report first before you can click the Drill Down field.", "Warning", MessageBoxButton.OK)
                    Exit Sub
                End If
                Dim oResultWindow As New SL.Product.ReportResult.ReportResult(SourceReportID, DisplayContent)
                oRadWindow = New RadWindow
                oRadWindow.Style = SL.Product.SharedDataLibrary.GlobalUIElements.ProductRadWindowTransparentStyle
 
 
                oRadWindow.Height = UIElementHelper.MainGrid.ActualHeight - 50
                oRadWindow.Width = UIElementHelper.MainGrid.ActualWidth - 50
                oRadWindow.WindowState = WindowState.Normal
                oRadWindow.ResizeMode = ResizeMode.NoResize
                oRadWindow.CanMove = False
                oRadWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner
 
 
                oRadWindow.Content = oResultWindow
 
 
                oRadWindow.ShowDialog()
                ' oResultWindow.ShowResultWindow()
            End If
        Catch ex As Exception
 
 
        End Try
    End Sub
 
 
    Private Sub lnkDisplay_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles lnkDisplay.Loaded
        Try
            Dim aryBoundString() As String = Split(DisplayContent, "||")
            'validate
            '0 = TargetReportID
            '1 = Fields Array
            '2 = Use Criteria
            '3 = Display Value
            Dim aryTemp() As String = Split(aryBoundString(3), "=")
            lnkDisplay.Content = String.Empty
            If aryTemp(0).ToUpper = "DISPLAY" Then lnkDisplay.Content = aryTemp(1).ToString
        Catch ex As Exception
            lnkDisplay.Content = String.Empty
            ToolTipService.SetToolTip(lnkDisplay, "Error Processing Display Value: " & ex.Message)
        End Try
    End Sub
 
 
    
   
End Class



I would appreciate any tips to get me moving in the right direction

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Jun 2012, 05:41 AM
Hi,

 You should implement INotifyPropertyChanged for your data items and raise PropertyChanged when you change a property value. If the UI is TwoWay bound to this property you will get immediate refresh. 

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Brian
Top achievements
Rank 1
answered on 05 Jun 2012, 06:29 PM
So far this has not been the solution as it appears the property value "DisplayContent" of the Cell Item doesn't change....it is apparently sorted as it should (without re-assignment of the property in the cell item template for each row)

The issue looks higher up...the grid does not seem to be redrawing the column contents. All other cells in the row sort and visibly change order....but these template bound cells appear the same...even though the underlying object reflects the change in sort.



Tags
GridView
Asked by
Brian
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Brian
Top achievements
Rank 1
Share this question
or