Hi Haneef,
Thanks for the update. We have created sample to achieve your requirement, please find the attached sample below,
Please let us know if you need any further assistance in customizing the sample.
Regards,Prakash V.
@(Html.EJ().Grid<object>("Filtering")
. . .
.AllowFiltering()
.AllowSorting()
)
public void ExportToPdf(string GridModel, string args)
{
PdfExport exp = new PdfExport();
var DataSource = new NorthwindDataContext().OrdersViews.Take(100).ToList(); //Get the Datasource
GridProperties GridProp = ConvertGridObject(GridModel); //Converted as a GridProperties
DataOperations dataOp = new DataOperations();
var FilteredData = dataOp.Execute(DataSource, GridProp); //Perform data operation to Filter or sort the datasource
JavaScriptSerializer serializer = new JavaScriptSerializer();
IEnumerable div = (IEnumerable)serializer.Deserialize(GridModel, typeof(IEnumerable));
Dictionary<string, dynamic> gridParams = serializer.Deserialize<Dictionary<string, dynamic>>(GridModel);
GridProperties gridProp = new GridProperties();
List<OrdersView> ListData = FilteredData.Cast<OrdersView>().ToList();
DrawGrid(ListData, gridParams);
}
private GridProperties ConvertGridObject(string gridProperty)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
IEnumerable div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable));
GridProperties 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)
{
Type type = property.PropertyType;
string serialize = serializer.Serialize(ds.Value);
object value = serializer.Deserialize(serialize, type);
property.SetValue(gridProp, value, null);
}
}
return gridProp;
} |