I have recently started working with the ExtJS javascript library. Its one of the coolest libraries that I have used so far. Initially it does look a bit intimidating, but then as you go through the samples and the different examples, you would get comfortable. And of course the forums are quite helpful.
Coming back to what this post is about.
For my project, we needed to display a grid report as per one of the business requirements. This report is based on a SQL query which takes sometime to run and it takes sometime to create a JSON object out of the result set. To be precise, it took 84 seconds for the data to be sent from the server.
What used to happen was that, for the first 30 seconds a display mask would be visible over the grid. But then at the end of the 30 seconds the display mask would disappear and the grid would be empty. The grid contained a data store which was fetching these records from the server
Even though, the data was being prepared at the server, it was not able to send the data to the client, since the connection used to timeout after 30 seconds.
After searching on Google, I came across a few suggestions, which asked me to include pagination in the grid. But then this was not acceptable to business. They wanted the whole report in one go.
After some more googling, I found that there is a connection object which can be defined for the data store. In this connection object, we can define the timeout limit. Once we define this connection object we can use this in our data store. And this solved my problem… at least for now. Following is the code snippet.
Though, if budget permits, you can check a user extension called live grid. This seems good.
http://www.siteartwork.de/livegrid_demo/
Coming back to what this post is about.
For my project, we needed to display a grid report as per one of the business requirements. This report is based on a SQL query which takes sometime to run and it takes sometime to create a JSON object out of the result set. To be precise, it took 84 seconds for the data to be sent from the server.
What used to happen was that, for the first 30 seconds a display mask would be visible over the grid. But then at the end of the 30 seconds the display mask would disappear and the grid would be empty. The grid contained a data store which was fetching these records from the server
Even though, the data was being prepared at the server, it was not able to send the data to the client, since the connection used to timeout after 30 seconds.
After searching on Google, I came across a few suggestions, which asked me to include pagination in the grid. But then this was not acceptable to business. They wanted the whole report in one go.
After some more googling, I found that there is a connection object which can be defined for the data store. In this connection object, we can define the timeout limit. Once we define this connection object we can use this in our data store. And this solved my problem… at least for now. Following is the code snippet.
var connObj = new Ext.data.Connection({
timeout : 120000,
url : ‘/jsp/dataSourceURL’,
method : ‘POST’
});
var dataStore = new Ext.data.Store({
// load using HTTP
proxy : new Ext.data.HttpProxy(connObj),
reader : new Ext.data.JsonReader({
root : ‘rows’,
totalProperty : ‘results’
}, recordFormat)
});
Hope this helps anyone stuck in a similar scenario. Though, if budget permits, you can check a user extension called live grid. This seems good.
http://www.siteartwork.de/livegrid_demo/
No comments:
Post a Comment