Issue in Standard Editor
Hi,
Am having a class contains the DateTime property to display the grid.
private DateTime _validity=DateTime.Today;
Field("Validity")]
public DateTime Validity
{
get
{
return _validity;
}
set
{
if (!Equals(_validity, value))
{
_validity = value;
Notify("Validity");
}
}
}
Issue is while setting the Format for that column the DateTime Editor is not working, the code block as follows.
this.grdSettings.Headers[0]["Validity"].Editable = true;
this.grdSettings.EditInPlace.Enabled = true;
this.grdSettings.Headers[0]["Validity"].Format = new Dapfor.Net.Formats.StringFormat("yyyy-dd-MM", "", "", null);
if am commenting "this.grdSettings.Headers[0]["Validity"].Format = new Dapfor.Net.Formats.StringFormat("yyyy-dd-MM", "", "", null);
" line Editor is working else editor is not working.
kindly provide a soltion for this issue.
Thanks & Regards
Sasee.G
-
Hello,
This happens because StringFormat doesn’t know how to parse string to DateTime. Indeed, each .Net object has Object.ToString() method, but doesn’t have Object.FromString() one. The same we can say about String.Fromat(…). Therefore you should implement your own format, indicating how to parse strings to values.
Example:
class MyDateFormat : IFormat
{
public string Format(IDataField dataField)
{
return string.Format("{0:yyyy-dd-MM}", dataField.Value);
}
public bool CanParse(string text, IDataField dataField)
{
DateTime v;
return DateTime.TryParse(text, out v);
}
public void Parse(string text, IDataField dataField)
{
DateTime v;
dataField.Value = DateTime.Parse(text);
}
}Best regards,
Dapfor
0
Please sign in to leave a comment.
Comments
1 comment