Posted 28 Aug 2014
Link to this post
There is no solution for the DateTimeOffset because is not superted as a data type
<telerik:GridDateTimeColumn DataField="CreatedDateTime" HeaderText="Date" SortExpression="CreatedDateTime" Visible="true" MaxLength="50" ItemStyle-Width="50" FilterControlWidth="150px" PickerType="DatePicker" DataFormatString="{0:g}" AutoPostBackOnFilter="true" CurrentFilterFunction="GreaterThanOrEqualTo" ShowFilterIcon="false" EnableTimeIndependentFiltering="true" DataType="System.DateTime">
</telerik:GridDateTimeColumn>
I did this in the backend and it is a work arround:
using Common.EntityModels;
using Common.Tools;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
namespace UI
{
public partial class LogsList : DetailBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadGridLogs_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
using (var tDBContext = new PlatformDB())
{
//Get the object.
var tLogs = (from tL in tDBContext.Logs
from tT in tDBContext.Tenants.Where(tT => tT.Id == tL.TenantId).DefaultIfEmpty()
from tU in tDBContext.Users.Where(tU => tU.Id == tL.UserId).DefaultIfEmpty()
select new
{
Id = tL.Id,
CreatedDateTime = tL.CreatedDateTime,
Description = tL.Description,
Server = tL.Server,
Application = tL.Application,
Module = tL.Module,
Function = tL.Function,
Type = tL.Type,
Tenant = (tL.TenantId != null) ? tT.Name : string.Empty,
User = (tL.UserId != null) ? tU.Name : string.Empty,
}).OrderByDescending(s => s.CreatedDateTime);
//Set the data table.
DataTable tDataTable = new DataTable();
tDataTable.Columns.Add("Id", typeof(long));
tDataTable.Columns.Add("CreatedDateTime", typeof(DateTime));
tDataTable.Columns.Add("Description", typeof(String));
tDataTable.Columns.Add("Server", typeof(String));
tDataTable.Columns.Add("Application", typeof(String));
tDataTable.Columns.Add("Module", typeof(String));
tDataTable.Columns.Add("Function", typeof(String));
tDataTable.Columns.Add("Type", typeof(string));
tDataTable.Columns.Add("TenantId", typeof(string));
tDataTable.Columns.Add("UserId", typeof(string));
//Fill data table.
foreach (var tLog in tLogs)
{
var tRow = tDataTable.NewRow();
tRow["Id"] = tLog.Id;
tRow["CreatedDateTime"] = tLog.CreatedDateTime.DateTime;
tRow["Description"] = tLog.Description;
tRow["Server"] = tLog.Server;
tRow["Application"] = tLog.Application;
tRow["Module"] = tLog.Module;
tRow["Function"] = tLog.Function;
tRow["Type"] = GetPlatformTypeText(typeof(PlatformTypes.LogType), tLog.Type.ToString());
tRow["TenantId"] = tLog.Tenant;
tRow["UserId"] = tLog.User;
tDataTable.Rows.Add(tRow);
}
this.RadGridLogs.DataSource = tDataTable;
}
}