Telerik RadGridView不会显示日期[英] Telerik RadGridView won't display Dates

本文是小编为大家收集整理的关于Telerik RadGridView不会显示日期的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在尝试以 ShortDate 格式在 RadGridView 中显示我的日期.

我用来生成列的代码是这样的:

<telerik:RadGridView x:Name="GenInq" Height="Auto" Width="Auto" 
  HorizontalAlignment="Left" Margin="0,-14,0,14" AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>  
        <telerik:GridViewColumn Header="Date" 
          Binding.XmlNamespaceManager="{Binding Path=Date, StringFormat='{}{0:dd.MM.yyyy}'}"/>
    </telerik:RadGridView.Columns>   
</telerik:RadGridView>`  

这是我用来填充 DataGrid 的查询:

var query = from loan in Loans  
            select new {Date = loan.StatusCommittedDate}  

DataGrid.ItemsSource = query.ToList();

我遇到的问题是日期条目在数据网格中显示为空白,它用空白条目填充网格.

推荐答案

我能够复制该问题并得到与您相同的结果.

您需要相应地更改列定义:

<telerik:GridViewDataColumn Header="Date"
    DataMemberBinding="{Binding Path=Date, StringFormat='{}{0:dd.MM.yyyy}'}"/>

本文地址:https://www.itbaoku.cn/post/1557078.html

问题描述

I'm trying to display my Date in a RadGridView in ShortDate Format.

The code I used to generate the column is this :

<telerik:RadGridView x:Name="GenInq" Height="Auto" Width="Auto" 
  HorizontalAlignment="Left" Margin="0,-14,0,14" AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>  
        <telerik:GridViewColumn Header="Date" 
          Binding.XmlNamespaceManager="{Binding Path=Date, StringFormat='{}{0:dd.MM.yyyy}'}"/>
    </telerik:RadGridView.Columns>   
</telerik:RadGridView>`  

This is my query i used to populate the DataGrid:

var query = from loan in Loans  
            select new {Date = loan.StatusCommittedDate}  

DataGrid.ItemsSource = query.ToList();

The issue I'm having is that the Date Entries are appearing BLANK in the datagrid, it populates the grid with blank entries.

推荐答案

I was able to replicate the issue and got the same results you did.

You need to change the column definition accordingly:

<telerik:GridViewDataColumn Header="Date"
    DataMemberBinding="{Binding Path=Date, StringFormat='{}{0:dd.MM.yyyy}'}"/>