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

GridView auto date format

5 Answers 217 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sarit Harel
Top achievements
Rank 1
Sarit Harel asked on 08 Feb 2010, 01:26 PM

Hello,

I am using telerik:RadGridView, my Items is set to a DataTable. 

the source Data tableis set to a SQL Query output, data is in a specific dateformat.

In case we setAutoGemerateColumns="true"; the data is displayed only in a modify format (thedata is date and time and the display automatic adds slashes, removes secondsand millisecond)

In the other case(AutoGemerateColumns="false") I have three columns specify and binded to each column;

the results are only visible by row count, the columns data is empty.

appreciate  your advise,

Thank you 

SaritHarel, IAI 

5 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 08 Feb 2010, 03:12 PM
Hi Sarit Harel,

Please paste me your XAML ( the definition of RadGridView with  columns ) and I will try to see where the problem is .

All the best,
Pavel Pavlov
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Sarit Harel
Top achievements
Rank 1
answered on 08 Feb 2010, 03:55 PM
Hi Pavel, 
As you requested my xaml:


 <Border x:Name="resultDataList" HorizontalAlignment="Right" Width="914.02" Height="195.796" Background="#FF7589AA" Canvas.Left="46" Canvas.Top="480" BorderBrush="#FF4D6F92" CornerRadius="2" BorderThickness="1">
            <Grid>
                <TextBlock Foreground="#FFFCFAFA" Width="50" Text="Results" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="10.991,8,0,0" VerticalAlignment="Top" Height="13.561"/>
                <telerik:RadGridView x:Name="resultsDataListView" AutoGenerateColumns="True" 
                                     ColumnsWidthMode="Fill" ForceCursor="True" Margin="3,30,3,3"
                                     Background="White" BorderBrush="#FF4E4E4E" IsTabStop="True" AllowDrop="True" ClipToBounds="True" 
                                     SnapsToDevicePixels="True" AreRowDetailsFrozen="False" AutoExpandGroups="True" MultipleSelect="False" ShowGroupPanel="False" 
                                     UseAlternateRowStyle="True" VerticalGridlinesBrush="Black" AutoGenerateHierarchyFromDataSet="False" CanUserInsertRows="False" IsReadOnly="True">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn Header="Start Time" DataMemberBinding="{Binding DateTimeFrom}"
                                                    Focusable="True" IsFilterable="True"/>
                        <telerik:GridViewDataColumn Header="End Time" DataMemberBinding="{Binding DateTimeTo}"
                                                    Focusable="True" IsFilterable="True"/>
                        <telerik:GridViewDataColumn Header="Duration" DataMemberBinding="{Binding Duration}" 
                                                    Focusable="True" IsFilterable="True" />
                    </telerik:RadGridView.Columns>
                    <telerik:RadGridView.RowAppearance>
                        <telerik:RowAppearanceSettings/>
                    </telerik:RadGridView.RowAppearance>
                </telerik:RadGridView>
                <Button x:Name="btnPlay" Style="{DynamicResource btnPlayStyle}" 
                 IsEnabled="False" ToolTip="Select a favorite formula"
                 Width="90" Height="22" d:IsStaticText="False" FontSize="13.333" FontFamily="Arial" HorizontalAlignment="Right" Margin="0,4.668,3,0" VerticalAlignment="Top">
                 <Button.DataContext>
                 <Image/>
                 </Button.DataContext>
                 <Image Width="11" Height="13" Source="Resources/Play_icon.png" Stretch="Fill" RenderTransformOrigin="-1.423,0.567" Margin="0,0,60,0"/>
                </Button>
            </Grid>
            
        </Border>




Thank you
Sarit
0
Pavel Pavlov
Telerik team
answered on 08 Feb 2010, 04:11 PM
Hello Sarit Harel,


Please try the following : In the Binding  when specifying the field name , please surround it with [ ]
For example:
Instead of : ="{Binding DateTimeFrom}" 
use : ="{Binding [DateTimeFrom]}" 

This is needed when binding to a datatable in WPF.

Best wishes,
Pavel Pavlov
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Sarit Harel
Top achievements
Rank 1
answered on 08 Feb 2010, 04:34 PM
Hello Pavel Pavlov 
Thank you for the quick replay it helpd !! but... I still  get the same data with AutoGenerateColumns = true or AutoGenerateColumns = false in the binded columns.   The RadGridview still automatic changes the format adding slashes and removing part of the time stamp.
Is there any way to diable this beahaivoir? Can there be a diffrent source for the GridView behaivor?

Thank you again
Sarit Harel
0
Pavel Pavlov
Telerik team
answered on 11 Feb 2010, 03:05 PM
Hi Sarit Harel,

To gain more control on  what format to be used when displaying DateTime , please use the

DataFormatString property of the column.

Best wishes,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Sarit Harel
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Sarit Harel
Top achievements
Rank 1
Share this question
or