Grid get filtered rows

Hello.

I want to get the filtered rows on a Grid.

By default, I set a DataTable to the DataSource property of the Grid. It display about +15,000 rows.  This is ok.

The user filter the rows using the Grid fitler functionality FilterType="Excel". For example, after filtering the Grid display 100 rows.

Now, I want in the server side, get this 100 rows. How can I do that? If I check the DataSource property, I get the +15,000 rows.

5 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team November 15, 2017 04:13 PM UTC

Hi Eligio, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we suspect that you want to get the filtered records in server side itself. So, we suggest you to send a ajax post server side along with the data. 

For an example, we have call for the ajax in the external button click event. 

Refer the below code example. 


<script type="text/javascript">  
         function buttonClick(args) {  
              
                 var obj = $("#Grid").ejGrid("instance");  
                 var data = obj.getFilteredRecords();  
                $.ajax({  
                    type: "POST",  
                    url: "/Grid/GridFeatures.aspx/Data",  
                    datatype: "json",  
                    contentType: "application/json; charset=utf-8",  
                    data: JSON.stringify({ gid: JSON.stringify(data) }),  
                    success: function (result) {  
                    }  
                });               
            }  
        </script>  


Server side operations:  
 
In below sample we have passed current filtered record details JSON object. At sever side the value is returned as below. 
 
        [WebMethod]  
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]  
        public static string Data(string gid)  
        {  
           return gid;  
        }  

Refer the help documentation. 


Regards, 
Thavasianand S. 




EL Eligio March 1, 2018 09:43 AM UTC

Hello.

I was trying this solution and seems to work. The problem is when selecting a large number of results in the grid, I get a 500 server error don't post in the server side. 

After testing I always get the error when selecting a large number of rows in the grid.

Any idea?


TS Thavasianand Sankaranarayanan Syncfusion Team March 2, 2018 01:01 PM UTC

Hi Eligio, 

We have analyzed your query and we suspect that you want to pass many to server end but you have encountered an exception. We are unable to reproduce the reported issue from our end. 

We have prepared a sample and it can be downloadable from the below location. 


Please provide the following details for better assistance. 

  1. Share screen shot or video demonstration of the issue.
  2. Share full Grid code example both server end and client end.
  3. Share Essential Studio version and browser version details.
  4. If possible share the issue reproducible sample or reproduce the issue in the attached sample.

Regards, 
Thavasianand S. 



EL Eligio March 23, 2018 04:05 PM UTC

Hello.

Thanks for the example. I have tried and it works. But, the problem is when there is a large number of data. 

Please, in your example, change this:

for (int i = 1; i < 1000; i++)
{
  order.Add(new Orders(code + 1, "ALFKI", i + 0, 2.3 * i, new DateTime(1991, 05, 15), "Berlin"));
  order.Add(new Orders(code + 2, "ANATR", i + 2, 3.3 * i, new DateTime(1990, 04, 04), "Madrid"));
  order.Add(new Orders(code + 3, "ANTON", i + 1, 4.3 * i, new DateTime(1957, 11, 30), "Cholchester"));
  order.Add(new Orders(code + 4, "BLONP", i + 3, 5.3 * i, new DateTime(1930, 10, 22), "Marseille"));
  order.Add(new Orders(code + 5, "BOLID", i + 4, 6.3 * i, new DateTime(1953, 02, 18), "Tsawassen"));
  code += 5;
}

Your original code was 100. With 100 it works. With 1000 it says: Error ocurred from error function in the ajax call.

My problem is that I have more or less 15000 rows in the grid. When I filter, maybe I get 2000 sometimes. And that is the problem.


Thanks


TS Thavasianand Sankaranarayanan Syncfusion Team March 26, 2018 11:33 AM UTC

Hi Eligio, 

We have analyzed your query and we are able to reproduce the reported issue “when passing more data from client end to server end” from our end. 

The issue is because of maximum Json length value. So, we suggest you to follow the below general solution link to avoid the issue.  


We have prepared a sample with above solution included and it can be downloadable from the below location. 

  
Regards, 
Thavasianand S. 


Loader.
Up arrow icon