WebGrid provides method to trigger exporting from client-side.
In this topic, you will learn how to trigger data export in Client-Side programmatically.
To trigger data export in Client-Side
- Open WebGrid Designer and select Allow Exporting.
- Place a html button in the WebForm and named it as Button1.
- Put the following code under Button1_onclick() client-side event.
function Button1_onclick()
{
// retrieves WebGrid's object
var WebGrid1 = ISGetObject("WebGrid1");
WebGrid1.ExportGrid("", "EXCEL", "PORTRAIT"); // export grid to excel
}
|
- Invoke Button1_onclick from the html button like following:
<input id="Button1" type="button" value="Export From Client" language="javascript"
onclick="return Button1_onclick()" />
- Run the project.