This is a migrated thread and some comments may be shown as answers.

DateTimePicker not honouring 24 hr format in pre rendered column definition for cell filter

3 Answers 561 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
lorraine
Top achievements
Rank 1
lorraine asked on 07 Jun 2017, 10:23 AM

I am trying to have the cell filter render a DateTimePicker with the parsed format as 24 hr - when i select 20.30 from the time picker portion it gets set in the rendered input as 03/06/2017 08:30 - I have tried numerous configurations for the template format arguments - could someone please point me in the right direction?

dcolumns[ci]["type"] = 'date';
dcolumns[ci]["filterable"] = {
     cell: {
              showOperators: false,
              template: function (args) {
                  args.element.kendoDateTimePicker({
                  timeFormat: "HH:mm",
                  format: "MM/dd/yyyy HH:mm",
                  parseFormats: ["MM/dd/yyyy hh:mm tt"]
                  });
                }
   }
}

3 Answers, 1 is accepted

Sort by
0
lorraine
Top achievements
Rank 1
answered on 07 Jun 2017, 10:27 AM
also tried
args.element.kendoDateTimePicker({
timeFormat: "HH:mm tt",
format: "MM/dd/yyyy HH:mm",
 parseFormats: ["MM/dd/yyyy HH:mm tt"]
});
0
lorraine
Top achievements
Rank 1
answered on 07 Jun 2017, 12:17 PM

if I remove the 
dcolumns[ci]["type"]="date";

the 24hr time is honoured - but my column is displayed in the table as timestamp (the orignal data format)

if I add 
dcolumns[ci]["format"]="{0:HH:mm:ss tt}";
my column is correctly formatted in date time BUT my 24 hour is no longer honoured

can anyone advise as to correct kendo grid column definition for a timestamp displayed as date time and the correct filterable cell template definition to honour 24hr format ?

0
lorraine
Top achievements
Rank 1
answered on 07 Jun 2017, 01:57 PM

Solved 
for anyone else having same issue

to display the timestamp as datetime create a template for the column

dcolumns[ci]["template"] = "#= kendo.toString(new Date(parseInt("+fieldName+")), 'yyyy-MM-dd HH:mm:ss')#";

remove the type = date from the column definition

code below

var fieldName = dcolumns[ci]["field"];
 dcolumns[ci]["template"] = "#= kendo.toString(new Date(parseInt(" + fieldName + ")), 'yyyy-MM-dd HH:mm:ss')#";
 dcolumns[ci]["filterable"] = {
      cell: {
              showOperators: false,
               template: function (args) {
                     args.element.kendoDateTimePicker({
                            timeFormat: "HH:mm tt",
                            format: "dd/MM/yyyy HH:mm",
                            parseFormats: ["dd/MM/yyyy hh:mm tt"]
                      });
                }
 }
};

 

Tags
Date/Time Pickers
Asked by
lorraine
Top achievements
Rank 1
Answers by
lorraine
Top achievements
Rank 1
Share this question
or