PDA

View Full Version : [CLOSED] After doing a 'Store1.DataBind()' how could I find the count of how many items are in the Store ???



Fahd
Jul 13, 2012, 6:11 PM
The syntax has change from the last version I was using which was v1.4

Or even finding out the items in the Grid that Store1 is binded too ??

Daniil
Jul 13, 2012, 7:02 PM
Hi,


The syntax has change from the last version I was using which was v1.4

Please provide more details.


Or even finding out the items in the Grid that Store1 is binded too ??

It would be best to call the GetCount or Length of the object which you apply to the Store DataSource.

Fahd
Jul 13, 2012, 7:20 PM
Thats the issue, when I call the Store1.DataBind(), it calls a Handler which I setup in the Page Load like this:



Store1.Proxy.Add(new AjaxProxy
{
NoCache = true,
Json = true,
ActionMethods = { Read = HttpMethod.GET },
Reader = { new JsonReader { Root = "Data", TotalProperty = "TotalRecords" } },
Url = Core.Web.ProcessController.GetHandlerUrl()
});


and my handler then return this:


context.Response.Write(JSON.Serialize(list));


So I don't have an object to that DataSource.


Hi,



Please provide more details.



It would be best to call the GetCount or Length of the object which you apply to the Store DataSource.

Daniil
Jul 13, 2012, 7:49 PM
If the Store is configured with the Proxy please call

store.LoadProxy();
to initiate a load request.

And there is no way to get the count of loaded records just after the LoadProxy calling, because they are loaded asynchronously via AJAX since you have set up the AjaxProxy.

You could get the count of records client side setting up a callback.

Example

JFunction fn = new JFunction()
{
Handler = "alert(records.length);",
Args = new string[] { "records", "operation", "success" }
};
Store store = this.GridPanel1.GetStore();
store.LoadProxy(new
{
callback = fn
});

Fahd
Jul 16, 2012, 4:12 PM
Ok, let me give it a shot, I have never implemented a callback function before...

Leave this tread open, I'll get back to you.

Thanks for pointing me in the right direction.


If the Store is configured with the Proxy please call

store.LoadProxy();
to initiate a load request.

And there is no way to get the count of loaded records just after the LoadProxy calling, because they are loaded asynchronously via AJAX since you have set up the AjaxProxy.

You could get the count of records client side setting up a callback.

Example

JFunction fn = new JFunction()
{
Handler = "alert(records.length);",
Args = new string[] { "records", "operation", "success" }
};
Store store = this.GridPanel1.GetStore();
store.LoadProxy(new
{
callback = fn
});

Daniil
Jul 25, 2012, 12:56 AM
I marked the thread as closed.

Though please feel free to post any new related info.

Fahd
Jul 25, 2012, 4:58 PM
Should I open a NEW thread with related info. or just post here ???


I marked the thread as closed.

Though please feel free to post any new related info.

Daniil
Jul 25, 2012, 5:34 PM
If it is tightly related to the current thread, please post here.

If it is another issue, please start a new thread.