- Home
- Forum
- ASP.NET Web Forms
- Error when updating Grid Data source using external filter from Pages other than first
Error when updating Grid Data source using external filter from Pages other than first
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 :--
Attachment: Error_5ec9c1b0.rar
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.
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
SIGN IN To post a reply.
8 Replies
VG
Vishal Gupta
January 20, 2017 07:25 AM UTC
SA
Saravanan Arunachalam
Syncfusion Team
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.
Regards,
Saravanan A.
VG
Vishal Gupta
January 23, 2017 11:17 AM UTC
Hi Saravanan,
Thanks for reply, Please find below the request format.
The Response Header is also attached.
- Request URL:http://localhost:52454/default.aspx/GridData?userId=
- Request Method:POST
- Status Code:200 OK
- Remote Address:[::1]:52454
- Response Headersview source
- Cache-Control:private, max-age=0
- Content-Length:1688
- Content-Type:application/json; charset=utf-8
- Date:Mon, 23 Jan 2017 11:09:48 GMT
- Server:Microsoft-IIS/8.0
- X-Powered-By:ASP.NET
- X-SourceFiles:=?UTF-8?B?QzpcVXNlcnNcTVRTTUdNVFxEb2N1bWVudHNcVmlzdWFsIFN0dWRpbyAyMDEzXFByb2plY3RzXFNhbXBsZUFwcFxTYW1wbGVBcHBcZGVmYXVsdC5hc3B4XEdyaWREYXRh?=
- Request Headersview source
- Accept:application/json, text/javascript, */*; q=0.01
- Accept-Encoding:gzip, deflate, br
- Accept-Language:en-US,en;q=0.8
- Connection:keep-alive
- Content-Length:76
- Content-Type:application/json; charset=UTF-8
- Cookie:ASP.NET_SessionId=zwm003qw2ydvqtojgnycvqmx
- Host:localhost:52454
- Origin:http://localhost:52454
- Referer:http://localhost:52454/Default.aspx
- 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
- X-Requested-With:XMLHttpRequest
- Query String Parametersview sourceview URL encoded
- userId:
- Request Payloadview source
- {value: {requiresCounts: true, params: {}, skip: 0, take: 10}, params: {}}
- params:{}
- value:{requiresCounts: true, params: {}, skip: 0, take: 10}
Attachment: response_header_7a8d51bc.rar
VG
Vishal Gupta
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.
[WebMethod]
[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()
}).ToList();
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.
SA
Saravanan Arunachalam
Syncfusion Team
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.
|
[Aspx.cs]
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();
this.Grid1.DataBind();
} |
Regards,
Saravanan A.
VG
Vishal Gupta
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.
VG
Vishal Gupta
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 !!
SA
Saravanan Arunachalam
Syncfusion Team
January 25, 2017 04:14 AM UTC
Hi Vishal,
Thanks for your update.
We are happy that the provided information helped you.
Regards,
Saravanan A.
SIGN IN To post a reply.
- 8 Replies
- 2 Participants
-
VG Vishal Gupta
- Jan 20, 2017 07:23 AM UTC
- Jan 25, 2017 04:14 AM UTC