gpt4 book ai didi

c# - Ext.Net GridPanel 日期列更改默认值

转载 作者:太空宇宙 更新时间:2023-11-03 23:42:18 26 4
gpt4 key购买 nike

我使用的是 ext.net 2.4 版本。网格上有一个日期列,我可以更改此列。网格由 sql server 填充。我的问题是:如果日期列为空(实际上该列不为空,sql server 端有默认值 01\01\1900)我的网格在网格上显示 01/01/1900。我想要网格是空的。我做到了,当我的类(class)填满网格时,我设置了列属性 Datetime.minvalue。是的,我确实列是空的,但我无法更改该列,给了我一条错误消息。

所以如果日期 01/01/1900 我不想看到日期,我想看到空的和 ?想要更改空列。你能帮帮我吗?

我的类(class):

   [Column]
public DateTime DeliveryDate
{
get
{
return this.deliveryDate == Convert.ToDateTime("01/01/1900")
? DateTime.MinValue
: this.deliveryDate.Value;
}

set { this.deliveryDate = value; }
}
<ext:DateColumn runat="server" Text="Servis Teslim Tarihi" DataIndex="DeliveryDate" Format="dd.MM.yyyy">
<Editor>
<ext:DateField runat="server" Format="dd.MM.yyyy"/>
</Editor>
</ext:DateColumn>

错误信息:

状态码:200

System.Exception: Unexpected token parsing date. Expected String, got Null. at Ext.Net.JSONDateTimeJsonConverter.ReadJson(JsonRea der reader, Type objectType, Object existingValue, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal (JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonRea der reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(Stri ng value, Type type, JsonSerializerSettings settings) at Ext.Net.JSON.Deserialize(String value, Type type, JsonSerializerSettings settings) at Ext.Net.JSON.Deserialize(String value, Type type, IList`1 converters, IContractResolver resolver) at Ext.Net.JSON.Deserialize(String value, Type type) at Ext.Net.DirectMethod.Invoke(Object target, HttpContext context, ParameterCollection args) at Ext.Net.DirectMethod.Invoke(Object target, ParameterCollection args) at Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument)

最佳答案

Sakir,谢谢你的帮助。那对我来说是工作。我的代码上次更新:

 var BeforeEdit = function (editor, e)
{

if (DateFormat(e.value) == '01.01.1900') {
e.value = '';
}

var DateFormat = function (date)
{
var curr_date = date.getDate().toString();
curr_date = curr_date.length > 1 ? curr_date : '0' + curr_date;

var curr_month = (1 + date.getMonth()).toString();
curr_month = curr_month.length > 1 ? curr_month : '0' + curr_month;
var curr_year = date.getFullYear();

return curr_date + "." + curr_month
+ "." + curr_year;
}

var myRenderer = function (value, metadata, record) {
if (DateFormat(value) == '01.01.1900') {
return "";
}
else
return DateFormat(value);
}
 <ext:CellEditing ID="CellEditing1" runat="server">
<Listeners>
<BeforeEdit Fn="BeforeEdit"/>
<Edit Fn="edit" />
</Listeners>
</ext:CellEditing>

关于c# - Ext.Net GridPanel 日期列更改默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28602808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com