Sending data to the server. Using Templates to Customize AutoComplete. Configuring all of the AutoComplete properties. Hooking into AutoComplete widget events. Calendar widget — basics. But, if you find yourself with a need for a highly customized tool, this HTML Editor supports a rich API, detailed configuration options, and easily accessible events for capturing and responding to use actions.
This is a control that is not appropriate for every site, but when you need something like this, it is a tremendous boost to productivity to find it all in such a useful and usable package.
In the next chapter, we will cover two very important Kendo widgets Menu and ListView. These widgets give you the ability to create responsive and feature-rich cascading page menus and organized data structures inside of your pages with the same Kendo approach that you have seen in all of the previous chapters.
Building on what you already know, using these new widgets will be easy and you should be up and running before you know it. The Kendo UI ListView widget is a control for visualizing a collection of data elements in a graphically pleasing way, especially if the data contains images or special styles.
Like all Kendo UI options, the configuration is consistent and sensible and allows you to create great-looking content, and provides display options for editing and selection. These controls are a good addition to your toolset for creating modern web pages.
Learning the Menu widget basics The Menu widget creates a fantastic drop-down menu with fly-out sections for the menu's contents. It is functionally rich and requires very little code for most implementations.
This creates a cascading effect where menu options can continue to expand as you move your mouse to different options. Here is the output from this code as the page is first loaded: Here is the Menu widget once the mouse is hovered over some of the elements in the menu. Try this on your own and see how fast and fluid the menu reacts to these events; it is very impressive.
The Menu widget, however, can also contain an imageurl property or a spritecssclass property to display an image along with the text. The image or sprite will appear as an icon to the left of the menu item text. Here is an example of using the imageurl property to show an icon for the Videos menu item To use a sprite, you would first set the background image of the menu items that should display the icons and then indicate a CSS class using the spritecssclass property that will specify the pixel offset for each particular icon.
Each menu item that has a spritecssclass property specified will automatically be decorated with the k-sprite CSS class so that this is wired up properly. The script section shows the spritecssclass property in use, which will assign that portion of the sprites image as the icon for that menu item. Menu items with URLs So far all of the examples I have shown are menu items that do not perform any actions when selected. All that you have to do is add the url property to the menu item in order to make it navigate when clicked on.
So, for any menu item that you want to navigate the user to a different page, include a url property, as shown here, and it will do so Notice how the web browser in this screenshot is showing the URL that the Videos menu item now navigates to.
These options are properties that can be configured, so that the Menu widget becomes suited to the needs of your web page and style. These configurations are specified at the point in code where you create the Menu widget. These sections will show you the options you can use. The animation property The animation action of the Kendo UI Menu can be configured for style, speed, and direction. When you configure the open action of the menu, Kendo will automatically assign the reverse behavior for the close action.
If you want to configure the close action independently of the open action, then you should configure them both separately, as shown here The available options here are top, bottom, left, and right. You can configure how the menu behaves in relation to mouse movement and clicks with the closeonclick, openonclick, and hoverdelay properties. You can configure whether the overall menu is oriented horizontally or vertically with the orientation property, and you can instruct the Kendo UI framework on how you want menus to fit to a page with the popupcollision property.
The insertafter and insertbefore methods work exactly the same way, except that they insert the new menu items at the same menu level and either after or before the reference item respectively. All of these methods return the Menu object to support method chaining.
Because of this, you can use a jquery selector type syntax to choose which item s to act upon in a familiar syntax. The other methods here, that is, close, open, and remove, only take a single parameter which is the selector of the HTML element s. Since this code is not considering which specific element was selected, it will fire the same code regardless of which element was selected.
The ListView widget retrieves its data through a Kendo DataSource object, it presents its data through one or more Kendo Template blocks, and it allows interaction with its data by giving the user the ability to both select and edit the data on the page.
This template determines how each item in the ListView will be rendered inside the web page. You can see how each element from the DataSource object has been rendered with the template, styled, and presented on the page as you would expect. We also added an event handler for the change event so that we can see an alert box that displays which elements have been selected.
In the notifyuser event handler function, I want to explain what is happening because it looks a bit confusing at first glance. The variable selected is given an array value of all of the selected elements' animalname property values. What is this. Well, when Kendo fires an event from a widget, it sets the context of that event handler so that this refers to the Kendo widget that fired the event.
So, in this case, this is a reference to the ListView itself. This means that calling this. The result of this code is an array of strings containing all of the animalname values of the selected elements from the ListView.
This is then displayed to the user using [array]. This is great because it means that you can accurately track selections that the user makes within your ListView and respond to those actions however you need to. Editing elements with ListView The ListView widget also provides a good syntax for allowing edits to the data within the DataSource object. You need to create a separate template to display that allows the user to make edits and then make sure that you assign some of the Kendo-specific class names, so that it displays and understand the commands correctly.
Get the reference through the. Here is a brief overview of the methods that take no parameters: add: Inserts an empty item into the ListView and prepares it for editing cancel: Cancels changes in currently edited items clearselection: Clears ListView's selected items and triggers the change event refresh: Reloads the data and reprints the ListView save: Saves the edited ListView item. If validation succeeds, it will call the datasource's sync method.
There are a few additional methods that do take parameters. The edit method This method edits the specified ListView item and triggers the edit event. This method takes a single parameter which is the ListView item that needs to be edited. It also triggers the datasource's sync method. If this method is called without any arguments, it will return a collection of all of the selected items in the ListView.
This is what we did in the code sample for selecting items. We have already seen some of these in our examples. These events can all be assigned to handlers during the ListView instantiation as we save earlier in the chapter. Here is a list: change: Fires when the ListView selection is changed databound: Fires when the ListView has received data from the DataSource object and is about to render it databinding: Fires when the data is about to be rendered on the page edit: Fires when the ListView enters edit mode remove: Fires before the ListView item is removed [ ].
Its API is very similar to the Kendo UI Menu widget, as you will see, and it is a powerful way to render accordion controls in a web page. Much like the Kendo UI Menu widget, its primary responsibility is to organize hierarchical content in a way that saves screen space, but still provides a sensible structure for users to understand. These content sections are broken up into panels with the PanelBar widget, or into tabs with the TabStrip widget.
In both cases, the effect is very similar and is a very useful way of keeping a web page from becoming too cluttered. This type of control is very useful for displaying lists of data that could potentially take up a large amount of screen space, but compressing it into a format that still makes sense to users. This HTML list will be reformatted into an accordion control that displays a single area of the list at a time.
As you will see, when you run the code sample, this allows a large amount of data to be visually compressed into a smaller space. It also allows the user to select which area of the list he or she is interested in viewing and hides the details of the other sections.
This gives a powerful demonstration of some of the commonality between Kendo widget implementations:. In this example, just as in the menu example, they are Music, Videos, Events, and News.
Just as before with the Menu widget, the PanelBar widget does not have to run from static HTML, it can be fuelled by a DataSource object of either local or remote data. In this code sample, we have also implemented a new feature, the imageurl property for the Videos tab.
By specifying the URL of an image in the project, the output will show this image next to the tab's title on the screen, which you can see in the following screenshot: To adapt this to use the MVC extension methods, you would create an MVC View with this source code in the cshtml ViewBag. We can also see here how the image is supplied through ASP. Adding sprite images to PanelBar items We have already seen some examples of how the PanelBar widget can contain an imageurl property to display an image next to a section title.
It can also use a more advanced image option by specifying a sprite image through the spritecssclass property. In either case, the image or sprite will appear as an icon to the left of the menu item text. As we have already partially seen, here is an example of using the imageurl property to show an icon for the Videos menu item The script section shows the spritecssclass property in use which will assign that portion of the sprite's image as the icon for that menu item.
All that we have to do is add the url property to the PanelBar item in order to make it navigate when clicked on. So, for any PanelBar item where we want to navigate the user to a different page, include a url property and it will do so This will reduce the overall size of the page since only one section of the PanelBar will be loaded at a time. It can also allow you to load content from other locations in your site that may change independently of the site that contains your PanelBar, which can reduce duplicate text or markup.
To enable this functionality, use the contenturls property of the PanelBar to indicate which sites contain the markup that should be placed inside the accordion: [ ]. It is a good idea to keep the content on these pages very simple so that it can fit into the PanelBar areas without being distorted. For the expand action, you can choose expandvertical, which is the normal action for expanding a PanelBar, and fadein which changes the opacity as it expands.
In fact, they perform nearly the same function except that the PanelBar Widget organizes content into panels that are stacked vertically while the TabStrip widget organizes content into panels that are stacked horizontally. They are so similar, in fact, that we will use nearly the same code to demonstrate both of them.
You have already seen the PanelBar widget in the preceding sections. Now we will take a look at the TabStrip widget and see how it functions within web pages.
TabStrip basics The TabStrip widget creates a series of tabs that are used to show only one specific section of content at a time. You have surely seen web pages that have tabs across the top of the screen to organize different types of material onto a single web page. The Kendo TabStrip widget is one way to create this effect on your own pages. This is all evident in the preceding code sample.
The unordered list contains all of the tab titles. This is how this particular example appears when run inside of a web browser: Using TabStrip with a datasource Much like the PanelBar, the TabStrip can be configured to use a datasource instead of being created on top of existing HTML markup already on a web page. The TabStrip widget, however just like the PanelBar widget , can also contain an imageurl property to display an image next to a tab's title.
In either case, the image or sprite will appear as an icon to the left of the tab's title text. By adding this property, the output now displays the image in the menu: [ ]. To use a sprite with the TabStrip, you can follow the same procedures as we discussed for the PanelBar.
For the expand action, you can choose expand:vertical, which is the normal action for expanding a TabStrip, and fadein which changes the opacity as it expands. For a categorized list of data elements that you need to compress into a smaller amount of screen space, the PanelBar widget is the perfect choice for your web page.
These sliders normally have tick marks and labels that indicate the highest and lowest numbers available as well as range between them. These widgets are great visual tools to help users select numbers on a fixed scale, instead of just typing in a value that may or may not be appropriate. This could be useful in a rating system, for example, or on any input control where only a certain set of numbers are allowed. As you will see, Kendo UI allows for a good level of configurability, so you can customize the appearance and functionality of the UI to suit your needs.
Introducing Slider and RangeSlider The first thing we should cover is the two different types of slider widgets that Kendo UI makes available. The Kendo UI RangeSlider widget is designed for more advanced scenarios where your page needs to capture a range a bottom and a top number of numbers from a user in a single page element instead of just a single value. It is important to understand that these slider widgets are special visual aids for use in supplying a number into an input HTML element.
The final output of a slider widget is the number that the user has selected and this number is set as the value of the input HTML element underneath. This is important so that the input element can then be posted inside of an HTML form and used by a web server on the other end when the form is posted.
For example, in the code below expressions data. The syntax used in a Kendo UI template is called "hash syntax". It is a very simple syntax and only used to accomplish two things.
For example, in the code below I am using the template and valueTemplate configuration options to pass the DropdownList widget two Kendo UI templates.
Notice that when passing a widget a template, the combining of the data with the template is left to the widget internals upon instantiation.
All you have to do is pass a compiled template to the widget, the widget will create the HTML for you using data from the widgets dataSource. Because widgets accept a function value for template configuration options any templating engine that offers a function that will return HTML with merged data can be used.
For example in the code example below the Handlers templating engine is being used in place of Kendo UI's i. List below are some of the known, modern, templating engines that compile a template into a function, which Kendo UI widgets can make use of without having to create additional functions.
Kendo UI Getting Started. Chapter 1. Key Benefits of Kendo UI 1. AngularJS directives started being shipped and maintained as part of kendo. AngularJS 1. AngularJS directives are maintained by Telerik, but several integration parts for completing solutions are available from the community.
Backbone , React Meteor. The easiest way to get started is to copy the file, rename it and translate the messages. Currently, translations are not available for every language. The full list of currently available translations can be found in the Kendo UI Core repository. When globalize. Kendo provides culture files. Several of the more sophisticated widgets have their own data abstractions that inherit from kendo. DataSource e. GanttDataSource , kendo. HierarchicalDataSource , kendo.
PivotDataSource , kendo. SchedulerDataSource , kendo. Chapter 2. Kendo UI Overview 2. Briefly in this section I will answer the question of what exactly Kendo UI is, and is not. Kendo UI Professional , the commercial version of Kendo used to develop line-of-business and data-centric applications, is divided into the following four parts: Web widgets - Common application widgets e. Mobile widgets, by design, also function on laptop and desktop browsers.