PDA

View Full Version : [CLOSED] how to reduce loading time for gridpanel with large data



trePjt
Dec 16, 2013, 6:06 AM
If the gridpanel bind with a large data source, it must need more loading time.

Is it help to reduce the loading time, if I enable paging in gridpanel?

Daniil
Dec 16, 2013, 2:10 PM
Hi @trePjt,

Yes, paging is a common solution for such cases.

Please clarify how many records do you load to the GridPanel? How many columns does the GridPanel have?

For the beginning, please just add a PagingToolbar to the GridPanel's BottomBar and specify some PageSize. For example, PageSize="100". Maybe, local paging will be enough for you.

trePjt
Dec 17, 2013, 2:58 AM
hi Daniil,

According to this example (http://examples2.ext.net/#/GridPanel/Paging_and_Sorting/JSON_WebService/), I have implement the paging like following.

Config the gridpanel in code behind


Store store1 = this.pnlSelect.GetStore();
AjaxProxy proxy = new AjaxProxy();
proxy.Url = "../../JsonProvider/Master/DropDown.ashx?master=tsklst&pageenable=1";
JsonReader reader = new JsonReader();
reader.Root = "data";
reader.TotalProperty = "totalCount";
proxy.Reader.Add(reader);
store1.Proxy.Add(proxy);



DropDown.ashx will return a Json string


public void ProcessRequest(HttpContext context)
{
string strJson = "";
try
{
context.Response.ContentType = "text/json";
string action = RequestUtility.GetQueryString("action");
switch (action)
{
default:
strJson = cboDropDown(context.Request);
break;
}
}
catch (Exception ex)
{
strJson = @"{success: false, error: '" + ex.ToString() + "'}";
}
ResponseUtility.Write(strJson);
}

private string cboDropDown(HttpRequest Request)
{
string strJson = "";
System.Data.DataSet ds = null;
string type = RequestUtility.GetQueryString("type");
string master = RequestUtility.GetQueryString("master");
string filterkey = RequestUtility.GetQueryString("filterkey");
bool allFlag = FacadeHelper.AllFlagToBool(RequestUtility.GetQuery String("all"));

string message = RequestUtility.GetQueryString("query");
ds = MasterDB.Query(master, message, type, filterkey);

if (allFlag)
FacadeHelper.AddAllFlag(ds);

System.Data.DataSet ds2 = ds.Copy();

string page = RequestUtility.GetQueryString("pageenable");

if (page.CompareTo("1") == 0)
{
ds2.Tables[0].Clear();
int start = Int32.Parse(RequestUtility.GetQueryString("start").ToString());
int limit = Int32.Parse(RequestUtility.GetQueryString("limit").ToString());

for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if(i>=start && i< start+limit)
{
ds2.Tables[0].Rows.Add(ds.Tables[0].Rows[i].ItemArray);
}
}
}

strJson = string.Format("{{totalCount:{1},'data':{0}", JSON.Serialize(ds2).Substring(10), ds.Tables[0].Rows.Count);

return strJson;
}


But the problem is, my grid also have header filter and implement as version 2.2 style.
Like this,


<ext:Column ID="Column1" runat="server" Text="_TSLTSKNO" DataIndex="TSLTSKNO" Flex="5">
<HeaderItems>
<ext:TextField ID="TSLTSKNOFilter" runat="server">
<Listeners>
<Change Handler="applyFilter(this);" Buffer="250" />
</Listeners>
<Plugins>
<ext:ClearButton ID="ClearButton1" runat="server" />
</Plugins>
</ext:TextField>
</HeaderItems>
</ext:Column>


So the filter can just affect on the current page only. Are there any solution? Did update to 2.4 and use FilterHeader plugin instead help?

Daniil
Dec 17, 2013, 12:30 PM
Yes. if you need to filter across all the records, you have to implement remote filtering.

Yes, a FilterHeader is a possible solution. We have an example of remote filtering.
http://examples2.ext.net/#/GridPanel/FilterHeader/Remote/

trePjt
Dec 18, 2013, 1:01 AM
Thanks Daniil. I will study on this case. You can mark this thread as closed.