Skip to content

Instantly share code, notes, and snippets.

@thilak-rao
Last active January 24, 2016 17:03
Show Gist options
  • Select an option

  • Save thilak-rao/e36bf52b854eed8a2372 to your computer and use it in GitHub Desktop.

Select an option

Save thilak-rao/e36bf52b854eed8a2372 to your computer and use it in GitHub Desktop.
Work in Progress: Daily Cheatsheet

Kendo UI Cheatsheet

Formatting

About kendo.format

Replaces each format item in a specified string with the text equivalent of a corresponding object's value. Uses toString for every format item.

kendo.format('Hello {0}', 'World');
// "Hello World"

kendo.format('Yesterday, I was {0}, today is am {1}', 'sad', 'happy');
// "Yesterday, I was sad, today is am happy"

Overriding Defaults

Number formatting depends on the current culture which by default is en-US. For "en-US negative currency formatting pattern is ($n). To override this behavior:

kendo.culture().numberFormat.currency.pattern[0] = '-$n';

Parsing Date

Parse string into appropriate format.

kendo.parseDate("01/30/2016", ["MM/dd/yyyy"]);

Date Formatting

kendo.toString(new Date(), 'd');
// "1/19/2016"

kendo.toString(new Date(), 'D');
// "Tuesday, January 19, 2016"

kendo.toString(new Date(), 'F');
// "Tuesday, January 19, 2016 12:44:44 PM"

kendo.toString(new Date(), 'g');
// "1/19/2016 12:45 PM"

kendo.toString(new Date(), 'M');
// "January 19"

kendo.toString(new Date(), 'u');
// "2016-01-19 12:46:18Z"

Full list of patterns: http://docs.telerik.com/kendo-ui/framework/globalization/dateformatting

Currency Formatting

kendo.format("{0:c}", -9999);
// ($9,999.00) or -$9,999.00 depending upon your locale. 

kendo.format("{0:c}", 9999);
// $9,999.00

Percentage Formatting

kendo.format("{0:p}", 0.2);
// "20.00 %"

kendo.format("{0:p}", 0.02);
// "2.00 %"

kendo.format("{0:p}", 0.002);
// "0.20 %"

kendo Template

Script tag:

<script id="some-template" type="text/x-kendo-template">
</script>

Render values as HTML: #= #

Uses HTML encoding to display values: #: #

Execute arbitrary Javascript code: # if (true) { # ... non-script content here ... # } #

Nexus 4: Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.122 Mobile Safari/537.36

iPhone 6: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment