グリッドの編集テンプレートが日付の編集時に問題を引き起こしているという奇妙な問題があります。
日付は UTC タイムゾーンでサーバーに保存されます。次のパターンを使用してタイムゾーンを設定します:-
private DateTime _minDate;
public DateTime MinDate
{
get { return _minDate; }
set { _minDate = DateTime.SpecifyKind(value, DateTimeKind.Utc); }
}
日付は、WebApi OData サービスを使用してグリッドに読み込まれます。
{
"Id":50088,
"ProductId":101437,
"Valor":"12224000",
"ISIN":"CH0122240002",
"Description":"Outperformance Bonus Certificate, Multi Shares",
"Provider":"CSIB",
"AlertedTicker":"KO UN",
"ProtectionPercentage":1.0,
"ProtectionType":"Protection Lost",
"UnderlyingCurrency":"USD",
"BarrierLevel":190.0,
"BarrierPercentage":70.0,
"BarrierType":"Low",
"BarrierId":0,
"EventStructureId":170378,
"Date":"2013-11-20T00:00:00Z",
"Comment":null,
"Confirm":false,
"Reject":false
}
OData サービスは、UTC 日付を正しくシリアル化し、日付をそのまま UI に取得します。
日付ピッカー コントロールを使用して日付を編集した後、キーボードを使用して入力しただけで、データが間違った形式でサーバーに送り返されます。
{
"odata.metadata":"http://local.host:51850/web/odata/$metadata#PendingBarrierAlerts/@Element",
"Id":50088,
"ProductId":101437,
"Valor":"12224000",
"ISIN":"CH0122240002",
"Description":"Outperformance Bonus Certificate, Multi Shares",
"Provider":"CSIB",
"AlertedTicker":"KO UN",
"ProtectionPercentage":1.0,
"ProtectionType":"Protection Lost",
"UnderlyingCurrency":"USD",
"BarrierLevel":190.0,
"BarrierPercentage":70.0,
"BarrierType":"Low",
"BarrierId":0,
"EventStructureId":170378,
"Date":"2013-11-20T23:00:00Z",
"Comment":null,
"Confirm":false,
"Reject":false
}
日付の時刻が変更されていることに注意してください。
グリッドで UTC 日付を編集し、OData をトランスポートおよびリモート データソースとして使用してサーバーに正しく返すにはどうすればよいですか?