Grid came into existence to fulfill the need of data presentation in applications. Since it’s creation it has been an undisputed choice for data presentation.
Exporting is an integral component of the grids. In most of the third party tools we have the exporting feature as an inbuilt component. In kendo grid yet we don’t have it so today I will be throwing some light on how to achieve it.
We will be exporting the data of a kendo grid into two different formats i.e Excel(XLS) and Word(doc).
Have a video for the functionality as well.
We need a button on click of which we will be initiating the Exporting into different above mentioned formats.
We can place these buttons either outside or at the toolbar of the Kendo Grid. For my demonstration I will be using the toolbar but the implementation will remain the same even if the buttons are placed outside the grid area.
So in the above code a kendo grid is created in the Jquery, this grid has a toolbar in which there are two Image buttons for exporting the data in Excel and word format.
On click of these buttons we are calling a method ExportData with are parameter that will differentiate that wheather the word or excel button is pressed.
In the ExportData method we will be exporting the data of the grid.
1> Get the DataSource : Retrieve the datasource of the kendo grid. If we want to take filtering also into account then we have to find the filtered datasource.
2> Declare the extension (Type of file in which the data should be exported).
3> Declare the Table header ( List of the Coulumns Header )
4> Fill the data into rows corresponding to the headers.
5> Create a link button dynamically click of which will initiate the downloading of the exported files.
This is how we can achieve the Exporting feature in the Kendo grid at the client side.
Keep Learning Keep Exploring 🙂