GridViewDataColumn formatiing from code mvvm

0 Answers 24 Views
GridView
Florin
Top achievements
Rank 2
Florin asked on 27 Jan 2023, 06:30 PM

Hy everyone,

I have a collection from DB:

var dynamicOutput = _sql.LoadData<dynamic, dynamic>(@"SELECT * FROM " + procedura.Trim() + "(@IdRamura, @DataRef)", p);

RaportRentabilitateGrid2.AddRange(dynamicOutput );

private ObservableRangeCollection<ExpandoObject> _raportRentabilitateGrid2 = new ObservableRangeCollection<ExpandoObject>();
public ObservableRangeCollection<ExpandoObject> RaportRentabilitateGrid2 {
            get { return _raportRentabilitateGrid2; }
            set {
                _raportRentabilitateGrid2 = value;
                OnPropertyChanged(nameof(RaportRentabilitateGrid2));
            }
}

So far everything works ok

I have the RadGridView:

<telerik:RadGridView x:Name="oRaportRentabilitateDet1" DockPanel.Dock="Top"
                                         Style="{StaticResource ContasGridviewStyle}"
                                         Background="White"
                                         AutoGenerateColumns="True"
                                         SelectionUnit="FullRow"
                                         SelectionMode="Single"
                                         HorizontalContentAlignment="Left"
                                         RowIndicatorVisibility="Collapsed"
                                         ShowGroupPanel="False"
                                         IsReadOnly="True"
                                         SelectedItem="{Binding SelectedRaportRentabilitateGrid2,Mode=TwoWay}"
                                         ItemsSource = "{Binding RaportRentabilitateGrid2, Mode=TwoWay}"
                                         VerticalAlignment="Stretch"
                                         Margin="5,0,5,10"
                                         IsSynchronizedWithCurrentItem="True"
                                         IsFilteringAllowed="False"
                                         ScrollViewer.VerticalScrollBarVisibility="Auto"
                                         ScrollViewer.HorizontalScrollBarVisibility="Auto">

And, for formatting the column in the RadGridView with the name DATA, i have the code:

            var delaColumn = oRaportRentabilitateGrid2.Columns["DATA"] as Telerik.Windows.Controls.GridViewDataColumn;
            delaColumn.DataFormatString = "dd.MM.yyyy";

But, it's not working...

I can't figure out why...

Thanks a lot.

Martin Ivanov
Telerik team
commented on 31 Jan 2023, 12:57 PM

I've tested this but I couldn't reproduce the issue. On my side the DataFormatString is applied properly. You can check the attached project and let me know if I am missing anything.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Florin
Top achievements
Rank 2
Share this question
or