We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How To Get Filtered Data from EjGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

118500 Mar 13,2015 06:36 AM Mar 25,2015 09:31 AM ASP.NET MVC 8
loading
Tags: Grid
Ganga
Asked On March 13, 2015 06:36 AM

I want to export the filtered data from Grid.But i Can't ..these are the codes i ve tried ...

Method 1:
 var gridObj = $("#Grid").ejGrid("instance");
 var data = gridObj.model.getFilteredRecords;
Method 2:
var gridObj= $("#Grid").ejGrid("model.getFilteredRecords");
Method 3:
var gridObj = $("#Grid").ejGrid("getFilteredRecords");


        

Balaji Marimuthu [Syncfusion]
Replied On March 16, 2015 08:23 AM

Hi Ganga,

Thanks for using Syncfusion Products.

Based on your requirement, we have created a sample to export the filtered records data in Grid. Please find the sample and code snippet.

Sample: Exporting34.zip

@(Html.EJ().Grid<Exporting34.OrdersView>("FlatGrid")

.Datasource((IEnumerable<object>)ViewBag.datasource)

.ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>

{

items.AddTool(ToolBarItems.ExcelExport);

items.AddTool(ToolBarItems.WordExport);

items.AddTool(ToolBarItems.PdfExport);

}))

.AllowFiltering()

.FilterSettings(f=>f.FilterType(FilterType.Menu))

. . . . . . . . .

)

If you need to export the filtered records data, you can simply perform the filter action then export the grid. The exported grid will contain only the filtered records, so there is no need for any additional operations to get the filtered records.

Please let us know if you have any queries.

Regards,

Balaji Marimuthu


Ganga
Replied On March 18, 2015 08:48 AM

Hello Balaji,
                     I tried to get only the filtered data from the grid.but using the following code i ll able to get the whole  data only even though using Filters .


 var gridObj = $("#Grid").ejGrid("instance");
 var data = gridObj.model.datasource



Balaji Marimuthu [Syncfusion]
Replied On March 19, 2015 09:23 AM

Hi Ganga,

Sorry about the inconvenience caused.

Query:# I tried to get only the filtered data from the grid.but using the following code i ll able to get the whole data only even though using Filters .

You can get the filtered records from the grid by using the following code snippet. Please find as below and for your convenience we have attached the sample.

Sample: Filterrecords.zip

@(Html.EJ().Grid<Exporting34.OrdersView>("Grid")

.Datasource((IEnumerable<object>)ViewBag.datasource)

. . . . . . .

.ClientSideEvents(eve=>eve.ActionComplete("complete"))

)

<script>

function complete(args)

{

if (args.requestType == "filtering") {

//you can get the filteredrecords by using the gridobject

var obj = $("#Grid").ejGrid("instance");

obj.getFilteredRecords();

//Either way to get the filteredrecords

var gridObj = $("#Grid").ejGrid("getFilteredRecords");

}

}

</script>

In the provided sample, we have achieved your requirement by using the getFilteredRecords api in Grid. And for your information by using the below code snippet which you have used, we can get the complete Grid dataSource.

var gridObj = $("#Grid").ejGrid("instance");

var data = gridObj.model.datasource

Please let us know if you have any queries.

Regards,

Balaji Marimuthu


Ganga
Replied On March 20, 2015 08:42 AM

Hai,


     This is my Sample Project.While i am using ShowSummary() ,Scrollable,Filter and Frozen columns were not working fine. i need the filtered data while clicking the Get filtered Data Button.I ve tried Somewhat.Can u solve this issue???

Attachment: Sample_Pass_Grid_Data_To_Controller_1a59a404.rar

Ganga
Replied On March 20, 2015 08:48 AM

While using Frozen Columns , I got the following error ..What is the solution for this???



Attachment: Grid_Problem_ce133209.rar

Prasanna Kumar Viswanathan [Syncfusion]
Replied On March 23, 2015 10:16 AM

Hi Ganga,

Thanks for using Syncfusion Products.

Query 1 : “While using ShowSummary() ,Scrollable,Filter and Frozen columns were not working fine”

While using Summary and bind the data using button it throws script error . So, the filter and scrolling features will not working fine. We considered the requirement “Throws a script error while using Summary with dataSource null” as a bug. We have logged a report on this and will fix the issue internally, also the fix will be included in "Volume/ Service pack details, in which the fix will be included", which has been scheduled to be rolled out in the month of Apr 2015.

We have also created an incident internally to have a follow up with this issue.

Query 2 : While using Frozen Columns , I got the following error”

Sorry for the inconvenience caused,

We analyze your sample and we unable to reproduce the issue at run time. Could you please provide me a detail in which scenario the issue is reproduced?

Please get back to us if you have any further assistance,

Regards,

Prasanna Kumar N.S.V


Ganga
Replied On March 24, 2015 02:34 AM

While i am filtering i need the sum of "Freight"  Column and also want to pass the filtered Data to controller.I am also using Frozen Columns for convenience. This is my sample Grid.Summary values are not updated while filtering. Grid Content were hidden while using Frozen Columns..  

Attachment: Freeze_Column_Grid_28ff273e.rar

Prasanna Kumar Viswanathan [Syncfusion]
Replied On March 25, 2015 09:31 AM

Hi Ganga,

Thanks for the update.

Query 1 : Grid Content were hidden while using Frozen Columns”

For your kind information in Essential Studio 12.4.0.24 we already created a defect report for this issue. This issue has been fixed in our latest Essential Studio version 12.4.0.34. So we suggest you to upgrade to the latest Essential studio version and you can download the latest version (12.4.0.34) from the following link:

Link : http://www.syncfusion.com/forums/118366/essential-studio-2014-volume-4-service-pack-2-release-v12-4-0-34-available-for-download

Query 2 : “Grid.Summary values are not updated while filtering”

We have analyze your sample and find that in summary rows property summary type is mentioned with an improper Api. So we suggest you to mention the proper api for the summary type, because it is an case sensitive. Please find the below code snippet .

summaryRows: [{ title: "sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight" }] }],

While rendering the data Source using ajax post we suggest you to set the dataSource using model initially, because If we set the dataSource as model it will reset the collection properties by default in the grid. So summary rows value also get reset. Please find the below code snippet :

var formatData = ej.parseJSON(data);

$("#FlatGrid").ejGrid('model.dataSource', formatData);

$("#FlatGrid").ejGrid({

// dataSource: formatData, // data must be array of json

showSummary: true,

summaryRows: [{ title: "sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight" }] }],

});

While rendering the dataSource using model the summary row will append two times in the footer. We considered the requirement “Summary row render double times while binding datasource using model” as a bug. We have logged a report on this and will fix the issue internally, also the fix will be included in "Volume/ Service pack details, in which the fix will be included", which has been scheduled to be rolled out in the month of Apr 2015.

Please kindly follow up the issue in the incident which we have created

For your convenience we have created a workaround for the above issue in sample and in this sample we remove one summary row by using a condition if the summary row length is greater than 1 remove the last summary row by using remove jQuery property .Please find the below code snippet:

success: function (data) {

var formatData = ej.parseJSON(data);

$("#FlatGrid").ejGrid('model.dataSource', formatData);

$("#FlatGrid").ejGrid({

// dataSource: formatData, // data must be array of json

showSummary: true,

summaryRows: [{ title: "sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight" }] }],

});

if ($(".e-gridsummary").length > 1)

$(".e-gridsummary:last").remove();

}

})

Please download the sample from the below link

Sample Link : http://www.syncfusion.com/downloads/support/forum/118500/Sample_Pass_Grid_Data_To_Controller-1026778922.zip

Please get back to us if you have any further assistance on this,

Regards,

Prasanna Kumar N.S.V


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;