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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error when updating Grid Data source using external filter from Pages other than first

Thread ID:





128418 Jan 20,2017 07:23 AM UTC Jan 25,2017 04:14 AM UTC ASP.NET Web Forms 8
Tags: Grid
Vishal Gupta
Asked On January 20, 2017 07:23 AM UTC

I have implemented an asp.net ejGrid and populated Paging and the Data from WebMethod Adapter, as my Data is there is sqlserver database and there are more than 10K records.
When I move to some other Page say Page 3, and then Search an item existing on Page1, then I get below error in console :--

Uncaught TypeError: Cannot read property 'items' of undefined
    at Object._initColumns (ej.web.all.min.js:10)
    at Object.addInitTemplate (ej.web.all.min.js:10)
    at Object._initGridRender (ej.web.all.min.js:10)
    at Object.<anonymous> (ej.web.all.min.js:10)
    at t.DataManager.<anonymous> (ScriptResource.axd:10)
    at j (jquery-2.1.4.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-2.1.4.min.js:2)
    at t.DataManager.<anonymous> (ScriptResource.axd:10)
    at t.DataManager.<anonymous> (ScriptResource.axd:10)
    at Object.success (ScriptResource.axd:10)

The Error Screenshot is attached..
Sample Code is also Attached.

 Also the Page Transition between pages is Slow.. Kindly help to guide the correct way of doing this.

Attachment: Error_5ec9c1b0.rar

Vishal Gupta
Replied On January 20, 2017 07:25 AM UTC

Same code is attached here.

Attachment: SampleApp_ae4046ad.rar

Saravanan Arunachalam [Syncfusion]
Replied On January 23, 2017 09:28 AM UTC

Hi Gupta, 
Thanks for contacting Syncfusion’s Support. 
It could be possibly occur due to return the improper formatted data from the server while searching. So, please ensure the returned data from the server as properly formatted (result and count). 
If you still faced the issue, please provide the following details. 
1.       Share the response header while searching like below image 
2.       Share the request format from the Network tab. 
Saravanan A. 

Vishal Gupta
Replied On January 23, 2017 11:17 AM UTC

Hi Saravanan,

Thanks for reply, Please find below the request format.

The Response Header is also attached.

    1. Request URL:
    2. Request Method:
    3. Status Code:
      200 OK
    4. Remote Address:
  1. Response Headersview source
    1. Cache-Control:
      private, max-age=0
    2. Content-Length:
    3. Content-Type:
      application/json; charset=utf-8
    4. Date:
      Mon, 23 Jan 2017 11:09:48 GMT
    5. Server:
    6. X-Powered-By:
    7. X-SourceFiles:
  2. Request Headersview source
    1. Accept:
      application/json, text/javascript, */*; q=0.01
    2. Accept-Encoding:
      gzip, deflate, br
    3. Accept-Language:
    4. Connection:
    5. Content-Length:
    6. Content-Type:
      application/json; charset=UTF-8
    7. Cookie:
    8. Host:
    9. Origin:
    10. Referer:
    11. User-Agent:
      Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
    12. X-Requested-With:
  3. Query String Parametersview sourceview URL encoded
    1. userId:
  4. Request Payloadview source
      1. {value: {requiresCounts: true, params: {}, skip: 0, take: 10}, params: {}}
        1. params:{}
        2. value:{requiresCounts: true, params: {}, skip: 0, take: 10}

Attachment: response_header_7a8d51bc.rar

Vishal Gupta
Replied On January 23, 2017 12:37 PM UTC

HI Team,

The actual issue is as below :--

I have asp.net ejgrid  having 10 pages and an external filter to select specific records. when I give values in the filter then dynamic sql is created and fresh data is extracted from database in the URL Adapter method show below. In this case, suppose only 3 records are fetched, now the values of skip and take should adjust automatically with the Data Source , but they are still comming as 40 and 10, due to which NO data is actually comming in result and error is comming.

Below is my web method, the GetUserRecords  function fetches value from database from dynamic sql created as per the external filter applied, and provide data back in dataTable.

        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static object GridData(int skip, int take)
            DataTable data = GetUserRecords();

            var sRec = (from DataRow row in data.Rows
                        select new UserTable
                            SeqNo = Convert.ToInt32(row["SeqN"].ToString()),
                            UserId = row["UserID"].ToString(),
                            Password = row["Password"].ToString(),
                            Priviledge = Convert.ToInt32(row["Priviledge"].ToString()),
                            Email = row["Email"].ToString(),
                            CompanyName = row["CompanyName"].ToString(),
                            CompanyId = Convert.ToInt32(row["CompanyId"].ToString()),
                            Comments = row["Comments"].ToString()

            var res = sRec.Skip(skip).Take(take).ToList(); 

            return new { result = res, count = sRec.Count };


In above function, If I am at Page 5 of the Grid and then I apply the external Filter,  It may result in a data table of 3 rows, but the Skip and Take above still have value as 40 and 10 
( as I have implemented paging with 10 records only in one page)

Kindly check and revert.

Saravanan Arunachalam [Syncfusion]
Replied On January 24, 2017 12:57 PM UTC

Hi Vishal, 
The cause of the issue is you have filtered the data externally with current page values (Skip and Take). So, we suggest you to filter the data with default pageSettings value. Please refer to the below code example. 
protected void cmdSearch_Click(object sender, EventArgs e) 
            sFilter = textSearchUserID.Text; 
            this.Grid1.DataManager = new DataSource(); 
            this.Grid1.DataManager.URL = "GridFeatures.aspx/GetData"; 
            this.Grid1.DataManager.Adaptor = "WebMethodAdaptor"; 
            this.Grid1.PageSettings = new PageSettings(); 
Saravanan A. 

Vishal Gupta
Replied On January 24, 2017 04:48 PM UTC

Thanks a  Lot saravanan, your suggestion worked like a charm.

Please guide me for another issue that "transition between pages in the grid is slow", this is because every time, I select a page, the DataManager URL GetData  is called and it again gets the complete records from database by firing the sql (select * from table) and then extract 10 records are per skip and take values.

Is there any better way to load the entire records once in some array or collection and then show records from this collection on page change, thereby avoiding database hit every time.  Please suggest.

Vishal Gupta
Replied On January 24, 2017 05:27 PM UTC

HI saravanan,

I have been able to store the values in a List collection and avoid database fetch on paging.,

my ALL issues stands closed now.

Thanks a lot for your help. You Rock !!

Saravanan Arunachalam [Syncfusion]
Replied On January 25, 2017 04:14 AM UTC

Hi Vishal,  
Thanks for your update.            
We are happy that the provided information helped you. 
Saravanan A. 


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon