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. Image for the cookie policy date
close icon

How To Get Filtered Data from EjGrid

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");


        

8 Replies

BM Balaji Marimuthu Syncfusion Team March 16, 2015 12:23 PM UTC

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



GA Ganga March 18, 2015 12:48 PM UTC

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




BM Balaji Marimuthu Syncfusion Team March 19, 2015 01:23 PM UTC

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



GA Ganga March 20, 2015 12:42 PM UTC

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


GA Ganga March 20, 2015 12:48 PM UTC

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



Attachment: Grid_Problem_ce133209.rar


PK Prasanna Kumar Viswanathan Syncfusion Team March 23, 2015 02:16 PM UTC

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



GA Ganga March 24, 2015 06:34 AM UTC

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


PK Prasanna Kumar Viswanathan Syncfusion Team March 25, 2015 01:31 PM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon