Hello,
I'm using 15.1 CLR 4.5 WebDataGrid in VS 2013 with columns bound to an SQL DataSource. For date columns I've added a WebDateTimeEditor as an edit provider. The WedDateTime editor's and the grid column's display and edit formats properties set to "g" and {0:g} (General Short Date and Short Time). When I attempt to edit any of the Date Time columns a JavaScript exception is thrown: "0x800a139e - JavaScript runtime error: Sys.FormatException: Input string was not in a correct format." I assume this is from the dynamically generated script. I noticed that script goes not contain a format option for "g" or "G":
Date._expandFormat = function Date$_expandFormat(dtf, format) { if (!format) { format = "F"; } var len = format.length; if (len === 1) { switch (format) { case "d": return dtf.ShortDatePattern; case "D": return dtf.LongDatePattern; case "t": return dtf.ShortTimePattern; case "T": return dtf.LongTimePattern; case "f": return dtf.LongDatePattern + " " + dtf.ShortTimePattern; case "F": return dtf.FullDateTimePattern; case "M": case "m": return dtf.MonthDayPattern; case "s": return dtf.SortableDateTimePattern; case "Y": case "y": return dtf.YearMonthPattern; default: throw Error.format(Sys.Res.formatInvalidString); } } else if ((len === 2) && (format.charAt(0) === "%")) { format = format.charAt(1); } return format;}
Is there anyway to force the "g" or "G" format to be excepted.
I am also having an issue with the Row Edit Template as well. No matter what control I use, whether it be a TextBox, WebDateTimeEditor, or WebMaskEditor with format settings the Datetime Columns always display in long date and time format.
Please help. I at a complete loss at this point.
Thank you,
Hello Customer Infragistic,
Thank you for contacting us!
As I understand you want to display/edit your date in Short Date or Short Time format. Those formats are represented in the method you posted:
case "d": return dtf.ShortDatePattern;
case "t": return dtf.ShortTimePattern;
Would you try to use "d" and "t" instead of "g"? Or do you mean any other format?
Also for the second part of your request, could you please send us some some working isolated sample that contains the grid and where the issue is easily reproducible?
PetKo, I was able to figure out adding the "d" and "t" format options the datetime cells. Thank you.
I hope this image come over OK. Along with the WebDataGrid code. here what is being displayed in the RowEdit Template.
I am glad you figured out the issue with the dates.
Please try to attach the image again, it is not attached to your message. Also, if a sample is required for me to reproduce the issue, could you send your sample as a working solution in a .zip, attached to your next message?
I am looking forward to hearing from you.
Thank you for your response. Due to time constraints I was not able to produce a working sample solution. however, I was able to attach a screenshot of the results I'm getting with the EditRowTemplate.
We are preferring attachments, because when you post such code snippets and the post becomes unreadable. Also sometimes the pasted code breaks its original format and we need to spend a lot of time to format it, to extract the most valuable information from it and to analyse it. It is slowing down our response and it is a waste of your time (waiting for the response). Furthermore, some code snippets are missing very valuable information, but in the attached projects, where the issue is reproducible, all needed information is in it.
What you can do in you case is to inject your own JS callback into the template in the following matter:
<ig:RowEditingClientBinding ColumnKey="Some_Key" ControlID="Some_ID" GetValueJavaScript="formatDate($get({ClientID}).value)" SetValueJavaScript="$get({ClientID}).value = formatDate({value})" />
and then in the formatDate implement your desired format:
function formatDate(inputDate) { // return formatted date }
In your case, when you define EditorControl with DisplayModeFormat and EditModeFormat, you need to stick into this format and for the template.
So, for example if you define DisplayModeFormat="d" EditModeFormat="d", then the formatted callback will be looks like this:
function formatDate(inputDate) { return inputDate.getFullYear() + "-" + ("0" + (inputDate.getMonth() + 1)).slice(-2) + "-" + ("0" + inputDate.getDate()).slice(-2); }
This should do the work for your case.
Thank worked perfectly. Thank you so much for your help..