New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Selection & Export

The Grid widget allows users to select specific cells and then to export them to Excel or a Telerik UI Chart for ASP.NET MVC .

For runnable example, refer to the Demo on copying/exporting selected cells

Getting Started

The following sections provide step-by-step instructions and examples on getting started with the Grid Selection Export functionality.

The selection export functionality relies on the client-side Grid API. In this example, a Telerik UI ContextMenu is used to execute Grid methods related to copying and exporting of the selected cells.

Enabling Excel Export

  1. Configure the Selectable property and apply the following settings:

  2. To take full advantage of the Excel export feature, download the JSZip library and include the file before the Kendo UI JavaScript files in the Layout.cshtml. For more information, refer to the article with the requirements.

        <script src=""></script>
        <script src=""></script>
        <script src=""></script>
            .Selectable(selectable => selectable
            .DataSource(dataSource => dataSource
                .Read(read => read.Action("Orders_Read", "Grid"))

Initializing a ContextMenu

  1. Add an icon for the ContextMenu.

        <span class='k-primary k-bg-primary k-icon k-i-menu contextMenuIcon'></span>
  2. Create the widget.

            .Items(items =>
                items.Add().Text("Copy").HtmlAttributes(new { id = "copy" });
                items.Add().Text("Copy with Headers").HtmlAttributes(new { id = "copyWithHeaders" });
                items.Add().Text("Export").HtmlAttributes(new { id = "export" });
                items.Add().Text("Export with Headers").HtmlAttributes(new { id = "exportWithHeaders" });
                items.Add().Text("Export to Chart").HtmlAttributes(new { id = "exportToChart" });
            .Events(ev => ev.Select("onSelect"))
  3. Define the event handling function.

        function onSelect(e) {
            var item =;
            switch (item) {
                case "copy":
                case "copyWithHeaders":
                case "export":
                case "exportWithHeaders":
                case "exportToChart":

Copying Selected Data

To enable users to copy the selected data, call the copySelectionToClipboard method.

    function copySelected() {
        let selected =;

        if (selected.length === 0) {
            kendo.alert("Please select cells before copying.");


    function copySelectedWithHeaders() {
        let selected =;

        if (selected.length === 0) {
            kendo.alert("Please select cells before copying.");


Exporting Selected Data to Excel

To enable users to export the selected data, call the exportSelectedToExcel method.

    function exportSelected() {
        let selected =;

        if (selected.length === 0) {
            kendo.alert("Please select cells before exporting.");

    function exportSelectedWithHeaders() {
        let selected =;

        if (selected.length === 0) {
            kendo.alert("Please select cells before exporting.");


Exporting Selected Data to Chart

To enable users to export the selected data to a Kendo UI Chart, call the getSelectedData method and initialize a Chart widget with the data.

  1. Add an empty div before initializing the Grid.

    <div id="chart-container"></div>
  2. Define the exportToChart method as demonstrated below.

            function exportToChart() {
                var container = $('#chart-container');
                var windowInstance = $('#chart-container').data('kendoWindow');
                var currInstance = container.find('.k-chart').data('kendoChart');
                /* Get the selected data. */
                var data = grid.getSelectedData();
                if (!data.length) {
                    kendo.alert('Please select cells before exporting.');
                /* If the user selects only a value(Freight) without a category(ShipCountry), set the ShipCountry name to Uknown.*/
                let unknownCountries = $.extend(true, [], data);
                unknownCountries.forEach(function (item, index, array) {
                    if (!array[index].ShipCountry) {
                        array[index].ShipCountry = "Unknown"
                /* Destroy the window instance. */
                if (windowInstance) {
                /* Destroy the chart instance. */
                if (currInstance) {
                /* Initialize a new window instance and increase it's width for every row that has been selected. This way the chart can fit properly. */
                let windowWidth = data.length > 5 ? data.length * 75 : 500;
                windowInstance = container.kendoWindow({ width: windowWidth }).data('kendoWindow');
                /* Create a chart using the data and append it to the window. */
                var element = $('<div></div>').appendTo(container);
                    dataSource: {
                        data: unknownCountries
                    series: [{
                        type: "column",
                        field: 'Freight'
                    categoryAxis: {field: "ShipCountry"}

Selection Types

The following selection types are supported:

  • Cell selection - the user holds down the CTRL key (Command key on Mac) and uses the left-click of the mouse to select cells.
  • Range selection - the user holds down the left-click on the mouse and drags across a range of cells.
  • Range and Cell selection - the user can combine the two approaches from above and select both a range and separate cells.
  • Range combination selection - the user performs a range selection and while holding the CTRL key (Command key on Mac), they perform another range selection.

Known Limitations

  • The copySelectionToClipboard, exportSelectedToExcel and getSelectedData methods do not work with rows that are persisted across different pages.
  • The Export to Chart method does not work with Range and Cell selection type.

See Also

In this article