jqgrid date sorting and formatting - sorting

I need to display date in two formats like mm/dd/yyyy and mm/dd/yyyy hh:mm:ss. I found we can use formatoptions in colmodel
formatoptions: {srcformat: 'ISO8601Long', newformat: 'm/d/y'}
and
formatoptions: {srcformat: 'ISO8601Long', newformat: 'm/d/y h:i:s'}
but i am getting output in jqgrid as mm/dd/yy. Shall any one give solution how to display mm/dd/yyyy. I need to do sorting for both columns.
Thanks in advance

You can use 'Y' instead of 'y' to display the year as 'yyyy' instead of 'yy':
formatter:'date', formatoptions: {srcformat:'ISO8601Long', newformat:'m/d/Y H:i:s'}
If you want to have no preceding nulls (without 0 padding) in the mounth and tha da you can use 'n/j/Y' instead of 'm/d/Y'. All different possible flags supported by the 'date' formatter you can find in the source code of the formatter.
UPDATED: The problem is that the short names of the srcformat like ISO8601Long, UniversalSortableDateTime, ShortDate and so on (see the documentation for details) can be used only with the remote grid data (datatype:'json' or datatype:xml). To make local sorting work correct you should use instead of srcformat:'ISO8601Long' to srcformat:'Y-m-d H:i:s'.
The demo shows that such change will make local sorting works correct.
I think that the restriction in srcformat could be interpret as a bug in jqGrid. So I recommend you to post the corresponding bug report in the trirand forum. Then Tony Tomov (the developer of jqGrid) could make the corresponding changes in the jqGrid code.

Many many thanks....I tried to bind jqgrid with remote data(json format) and I wanted to display the date format as dd/mm/yyyy. after using the below options
formatter:'date', formatoptions: {srcformat:'ISO8601Long', newformat:'d/m/Y'}
It's working perfectly.

Related

User facing date field granularity control

I'm trying to give my users the option to select the date field granularity of their choice, such as day, week, month or year. This is normally controlled on each graph in the menu show below but this isn't available in a published dashboard:
My first idea was to create a calculated field that truncates my desired date based on a parameter that I expose through a control. This would like something like this, truncDate(${intervalParameter}, {dateColumn}). The problem with this is that the first argument of the truncDate function must one of valid string literals and will throw an error before saving if it isn't.
Does anyone know of any other ways of achieving this? Or maybe some sneaky way of getting around the error?
I figured out a work around using ifElse.
ifElse(
${intervalParameter} = 'Day', truncDate("DD", {dateColumn}),
${intervalParameter} = 'Week', truncDate("WK", {dateColumn}),
${intervalParameter} = 'Month', truncDate("MM", {dateColumn}),
truncDate("DD", {dateColumn})
)
There might be better solutions out there but this is what I've come up with.

ZEN : Allow multiple date formats in a dateText control and converting them to the YYYY-MM-DD

There is a finite list of date formats that users want to use to enter a date in a form. These formats include single digits for month and day and double digits for year. The field is represented by a dateText control.
How would one get to allow a dateText control to accept multiple date formats ? I see only 3 listed (https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GZCP_forms_dateText), do those include using single digits for month and day ?
I tried to set the value of format = "#(myPageProperty.myValue)# " but I got a compilation error in Studio so that went nowhere. Has anyone ever been able to set the format value depending on the user input value?
I am guessing that the control input value must be converted to the YYYY-MM-DD before validation. I am open to calling a javascript function to do that but where would be the best place to put it?
for details see Class %ZEN.Component.dateText
setting format:
Property format As %ZEN.Datatype.string(MAXLEN = 3, **VALUELIST = ",MDY,DMY,YMD",** ZENEXPRESSION = 1)
you have exactly 3 formats or ""
Your guess on values is correct and documented:
/// The value of this control is always in the canonical form: YYYY-MM-DD
As this is one of the oldest components of ZEN your only chance to achieve
your way of operation is to create your own version inheriting from
Class %ZEN.Component.dateText and overloading the parts you want to change

Range values extraction in Kendo spreadsheet changes dates to integers

I am using a Kendo spreadsheet to import data from an Excel file so I can plug it into an SQL Server database using Ajax callbacks. The Ajax callbacks work fine, but I have determined that any Date strings are being converted to an integer offset from a base date of 12/30/1899. I have submitted a support ticket to Telerik, but they do not seem to understand the problem.
The data is displayed in the Kendo spreadsheet appropriately as a date. Kendo converts a date input as "12/1/2015" to "12-1-2015".
I am using the latest version of the ASP.NET MVC 5 wrapper, but the JavaScript code is the 2016-1-226-545 version of the JavaScript. The wrapper version seems to be irrelevant, but later versions of the JavaScript have the gulpfile.js, and this conflicts with the Bundleconfig interface on my ASP.NET MVC 5 project, so I simply work with the last version of the JavaScript that works for my setup.
The spreadsheet I am working with is pretty basic to start:
#(
Html.Kendo().Spreadsheet()
.Name("SiteSlotDataSS")
.Rows(10)
.Columns(4).ColumnWidth(100)
.Sheets(sheets =>
{
sheets.Add()
.Name("Study Data");
}
)
)
I use the import option to pull in an Excel spreadsheet and use a simple button with a click event routine to copy the data to a string array to send to the Ajax callback. I have confirmed that the data being sent to the server controller is the same as it is on the client side before being sent. The Date conversion to an integer occurs when the values are extracted from the range.
The code in question that selects the values is:
values = sheet.range("A" + headerRows.toString() + ":" + endRange + (headerRows + rows).toString()).values();
This produces the correct translation of every other column except for columns containing dates.
I tried the following to brute-force the issue, without success:
for (var x = 0; x <= rows; x++) {
sheet.range("K" + (headerRows + x).toString()).format(kendo.spreadsheet.formatting.date);
}
I could try a date function to convert the date back into the original value, but everyone pretty much knows how Telerik's documentation is a bit skimpy and overall simply a nightmare to find answers to questions with.
What is the solution?
It appears that Kendo Spreadsheet stores the date values as an integer offset from 12/30/1899 in days. I determined the "0" value by entering a date of 1/1/1901 to see what came back, then 1/1/1900. The result of the latter was "2", making the base date 12/30/1899. Taking the data and converting it at the server seems to be the best option. I don't really expect much of a response from Telerik.
I have addressed the storage issue with Telerik, and they have acknowledged there is a bug in the spreadsheet widget.
For now, the solution is to bring the values array one row at a time back to the server and do the data conversion server-side. The integer that is returned in the values array for dates is the way the Kendo Spreadsheet stores the information client-side. Formatting the column simply will not do anything but change the client-side display. It will not change how Kendo returns the values matrix from the spreadsheet range selected.
Firstly, I think you mean 12/31/1899. It makes no sense to refer anything to 12/30/1899.
Excel dates start with 1/1/1900, just as do your Kendo (Japanese: "the way of the sword") dates. If you're getting an integer, forcibly coerce it to the corresponding date on the receiving by merely FORMATTING THE COLUMN. There is no need for a specific function to "convert" days-since-1900 counts to text dates (MM/DD/YYYY), as they are the SAME, differing only in human-readable representation.
Of course, it wasn't clear from your description whether Excel was on the input side or the output side of the problem.

In jqgrid, Is it possible to use select formatter without setting editoptions?

Since one of my jqgrid column is not editable,so I do not set required value info i.e.{value:"1:John;2:Smith"} to editoptions, instead, I set formatter:select and value info to formatoptions. When I look at the js sourcecode of select formatter it tightly coupled with editoptions especially for getting "multiple" property of it. Is it possible to achieve this without writing custom formatter?
formatter:select
formatoptions:{value:"1:John;2:Smith"}
data being sent to this column is "1" or "2", and I expect from jqGrid to display John or Smith.
thanks,
Alper.
You are right, that the code of the select formatter could be improved to use opts.colModel.formatoptions.multiple in the line in the same way as it will be used opts.colModel.editoptions.multiple in the line of code.
Nevertheless I don't think that it's a real problem. If you has no editable property in the column or if you has editable: false the column stay non-editable even if you use editoptions.
So I agree you that the usage of formatoptions.multiple would be better, but I think that it's "nice to have" problem only.

How I can format date in report to appear exactly as I want - RDLC

I have a report in my application and this report will show a long date from db and I used this expression to make it shorter:
=FormatDateTime(Fields!StatementDate.Value,DateFormat.ShortDate)
and the date will show like this : 1/1/2010
I need to make it like this : 2010/1/1
How I can do it?
That expression do the trick
=CDate(Fields!Fecha.Value).ToString("yyyy/M/d")
I think that it is a lot cleaner to use the Format property rather than format it in your expressions:
http://msdn.microsoft.com/en-us/library/ms252080%28v=vs.90%29.aspx
You can use the standard .NET formatting strings.
Value=Fields!StatementDate.Value
Format=yyyy/M/d
Fields!StatementDate.Value will need to be a DateTime, if not you can try convert it:
Value=CDate(Fields!StatementDate.Value)
=CDate(Fields!StatementDate.Value).ToShortDateString()

Resources