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

How to format date in kendoUI grid when initialize from table content

3 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yang
Top achievements
Rank 1
Yang asked on 10 Jul 2017, 01:28 AM

As the title, I initialize kendo UI grid from exiting html table. There is one date column inside the table, and I would like to format it to "yyyy-MMM-dd" format. And I would like to add header filter to do it as well. 

 

The code can be found here: http://dojo.telerik.com/IVimEc

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 11 Jul 2017, 02:27 PM
Hi Yang,
  
I am afraid that formatting is not supported out of the box when initializing the grid from HTML table. As a workaround you can override the _columns function in your kendo.grid.js file in order to add a format attribute or initialize the grid from div.

In order to add filter header enable filtering functionality.


Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Andrea
Top achievements
Rank 1
answered on 15 Feb 2018, 02:27 PM

Hi, I believe this is going to work about formatting dates, i don't know how to do for filteriong though

<th data-field="year" data-type="date"
                            data-template="#=kendo.format('{0:dd-MMM-yyyy}',year)#">Year</th>

http://dojo.telerik.com/IVimEc/11

0
Georgi
Telerik team
answered on 19 Feb 2018, 06:56 AM
Hello Andrea,

Thank you for sharing your solution with the community.

It is possible to enable filtering by setting the filterable property to true:

$("#grid").kendoGrid({
       height: 550,
       sortable: true,
       filterable:true
     });

In order to disable the filtering for certain column set the data-filterable attribute to false.

Below you will find a modified version of the provided sample which demonstrates how to enable filtering when the grid is initialized from table:



Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Yang
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Andrea
Top achievements
Rank 1
Share this question
or