我使用的是ext.net 2.4版本。网格上有一个日期列,我可以更改此列。网格从sql server填充。我的问题是:如果日期列为空(实际上列不为空,从sql服务器端有默认值01 \ 01 \ 1900)我的网格显示在网格上01/01/1900。我想网格显示我是空的。我做了它,当我的类填充网格时,我设置了列属性Datetime.minvalue。是的,我确实列是空的,但我无法更改列,给了我一个erorr消息。
所以如果日期01/01/1900我不想看日期,我想看空吗?想要更改空列。你能帮我吗?
我的班级:
[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>
&#13;
Erorr留言:
状态代码:200
System.Exception:意外的令牌解析日期。预期的字符串,得到了空。在Newtonsoft.Json的Newtonoft.Json.Serialization.JsonSerializerIntern alReader.DeserializeConvertable(JsonConverter转换器,JsonReader reader,Type objectType,Object existingValue)的Ext.Net.JSONDateTimeJsonConverter.ReadJson(JsonRea der reader,Type objectType,Object existingValue,JsonSerializer serializer)在Newtonsoft.Json.JsonSerializer.Deserialize(JsonRea der reader,Type objectType)的Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader,Type objectType)中的.Serialization.JsonSerializerIntern alReader.Deserialize(JsonReader reader,Type objectType,Boolean checkAdditionalContent)在Ext.Net.JSON.Deserialize的Ext.Net.JSON.Deserialize(字符串值,类型类型,JsonSerializerSettings设置)的.Json.JsonConvert.DeserializeObject(Stri ng值,Type type,JsonSerializerSettings设置)(String value,Type type,在Ext.Net.DirectMethod.Invoke(Obj)的Ext.Net.JSON.Deserialize(字符串值,类型类型)的IList`1转换器,IContractResolver解析器)在Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument)的Ext.Net.DirectMethod.Invoke(Object target,ParameterCollection args)中的ect target,HttpContext context,ParameterCollection args)
答案 0 :(得分:2)
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);
}
&#13;
<ext:CellEditing ID="CellEditing1" runat="server">
<Listeners>
<BeforeEdit Fn="BeforeEdit"/>
<Edit Fn="edit" />
</Listeners>
</ext:CellEditing>
&#13;
答案 1 :(得分:1)
<ext:DateColumn runat="server" Text="Servis Teslim Tarihi" DataIndex="DeliveryDate"
Format="dd.MM.yyyy">
<Renderer Fn="myRenderer" />
<Editor>
<ext:DateField runat="server" Format="dd.MM.yyyy"/>
</Editor>
</ext:DateColumn>
和脚本;
<script type="text/javascript">
var myRenderer = function(value, metadata, record) {
if(value==='01/01/1900')
return "";
}
</script>