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

Kendo Grid - Export Into Excel only selected rows

3 Answers 2462 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 16 Dec 2019, 04:43 PM

How to export excel  with only selected rows, selection is based on a column value? 

Note: JQuery Grid

 

3 Answers, 1 is accepted

Sort by
0
Hetali
Telerik team
answered on 17 Dec 2019, 09:53 PM

Hi Michael,

We have a dedicated KB article to Export the Checked Columns in the Kendo UI Grid to Excel.

As you have mentioned that the selection is based on a column value, please use the dataBound event to check the column in the Dojo sample of the KB article. For example:

$("#grid").kendoGrid({
  dataBound: function() {
    var view = this.dataSource.view();
    this.items().each(function(index, row) {
      if(view[index].category === "Food")   // Selects the row if the Catergory is Food.
        view[index].check = true;
      else
        view[index].check = false;
      kendo.bind(row, view[index]);
    });
  }
});


Bind the check value with the checkbox in the columns.template property as seen below:

$("#grid").kendoGrid({
  columns: [
    { template: "<input type='checkbox' data-bind='checked: check'/>" }
  ]
});


In this Dojo example, the Grid selects the rows with the Category 'Food' and exports them to Excel.

Please let me know if this helps. If I have misunderstood your query, could you respond with a detailed explanation? I will further help you with the modification.

Regards,
Hetali
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Kamaraj
Top achievements
Rank 1
Veteran
answered on 09 Nov 2020, 09:21 AM

Hi Team,

I am using Angular with KendoGrid .I have to upload only when the records are selected by check box otherwise it will not export to all the records to excel .Can some one help me by provide the right links or suitable code for resolving this issue with working code .

Thanks and Regards,

Kamaraj.P

 

 

 

0
Martin
Telerik team
answered on 11 Nov 2020, 08:24 AM

Hello Kamaraj,

In order to export specific data in excel format, please check the following article from our documentation:

https://www.telerik.com/kendo-angular-ui/components/grid/export/excel-export/#exporting-specific-data

The [fetchData] callback returns the collection that will be exported. Apply the state of the Grid in fetchData callback function.

Regarding the selection the most straight-forward approach to keep an automatically updated collection of all selected Grid rows is via the kendoGridSelectBy directive and the selectedKeys (which will be bound to the actual collection of selected Grid items):

https://www.telerik.com/kendo-angular-ui/components/grid/selection/persisting/#persisting-the-row-selection

The fetchData callback can return the collection of selected items. Please check the following example:

https://stackblitz.com/edit/angular-7ugysd-hl7naz?file=app/app.component.ts

I hope this helps.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Hetali
Telerik team
Kamaraj
Top achievements
Rank 1
Veteran
Martin
Telerik team
Share this question
or