How to export the Grid in AngularJS?

453 views Asked by At

I have seen export to excel functionality for syncfusion gird at http://www.syncfusion.com/kb/5040/how-to-export-the-grid-in-angularjs

I have to do export functionality for syncfusion grid. So can any give sample code for that

 <div id="Grid" ej-grid e-columns="columns" e-datasource="data" e-toolbarsettings='tools' e-toolbarclick="toolbarHandler"  e-allowpaging="true"></div>
2

There are 2 answers

0
Madhu On

Syncfusion.EJ and Syncfusion.EJ.Export are needed to perform exporting grid content, you can find them from the location

C:\Program Files (x86)\Syncfusion\Essential Studio\xx.x.x.xx\Assemblies

where xx.x.xx.xx is version of essential studio.

http://help.syncfusion.com/ug/js/index.html#!Documents/exporting3.htm

2
Luc Nguyen On

Here you are:

public GridProperties ConvertGridObject(string gridProperty)
    {
        var serializer = new JavaScriptSerializer();
        var div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable));
        var gridProp = new GridProperties();
        foreach (KeyValuePair<string, object> ds in div)
        {
            var property = gridProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
            if (property != null)
            {
                var type = property.PropertyType;
                var serialize = serializer.Serialize(ds.Value);
                var value = serializer.Deserialize(serialize, type);
                property.SetValue(gridProp, value, null);
            }
        }
        return gridProp;
    }