How to change displayed group name for grouped LightSwitch datagrid? RRS feed

  • Question

  • Hi

    I have screen code which group datagrid data by product name when screen starts:

    Imports Microsoft.LightSwitch.Presentation.Extensions
    Imports System.Windows.Data
    Imports System.Windows.Controls
    Imports System.ComponentModel
    Namespace LightSwitchApplication
        Public Class NEW_SearchStock_Filter
            Private _grid As IContentItemProxy
            Private _dataGrid As DataGrid
            Private _periodsLoaded As Boolean = False
            Private Sub NEW_SearchStock_Filter_Created()
                _grid = Me.FindControl("grid")
                AddHandler _grid.ControlAvailable, AddressOf _grid_ControlAvailable
            End Sub
            Private Sub _grid_ControlAvailable(sender As Object, e As ControlAvailableEventArgs)
                RemoveHandler _grid.ControlAvailable, AddressOf _grid_ControlAvailable
                _dataGrid = TryCast(e.Control, DataGrid)
                If (_periodsLoaded) Then _
            End Sub
            Private Sub GroupGridColumns()
                        Dim view As PagedCollectionView = New PagedCollectionView(_dataGrid.ItemsSource)
                        Using view.DeferRefresh()
                            ' What do you want to group by
                            view.GroupDescriptions.Add(New PropertyGroupDescription("الصنف"))
                            ' What do you want to order by
                            view.SortDescriptions.Add(New SortDescription("الصنف", ListSortDirection.Descending))
                            view.SortDescriptions.Add(New SortDescription("الكمية", ListSortDirection.Ascending))
                            view.SortDescriptions.Add(New SortDescription("المورد", ListSortDirection.Ascending))
                        End Using
                        _dataGrid.ItemsSource = view
                    End Sub)
            End Sub
        Private Sub Stock_Filter_Loaded(succeeded As Boolean)
                _periodsLoaded = True
                If (Not _dataGrid Is Nothing) Then GroupGridColumns()
    End Sub
        End Class
    End Namespace

    My problem is my tables columns' titles are in English with display names in Arabic..

    when I group by any field of the table the datagrid shows group by Product_Name instead of "المنتج" .. and I need it to be displayed as the columns display name not the column name.

    instead of Product_Name .. but the datagrid failed to group data and raised error "At least one object must implement icomparable"

    Please advise.

    Ehab, Egy.

    Saturday, October 11, 2014 9:03 PM


All replies