PDA

View Full Version : [CLOSED] Store's TotalCountChange is not being fired



RCN
Feb 04, 2015, 12:45 AM
On the following example, when grid page is changed, total is modified from 100 to 200. The PagingToolbar reflects the changes as expected but Store's TotalCountChange is not fired (line 11).

20221

20231



<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
</head>
<body>
<ext:ResourceManager runat="server" Locale="en" ScriptMode="Debug" />
<ext:GridPanel Title="Ext.Net" Border="true" Width="500" Height="250" runat="server">
<Store>
<ext:Store AutoLoad="true" PageSize="50" runat="server">
<Listeners>
<TotalCountChange Handler="Ext.Msg.alert('Information', 'Total Count Change');" />
</Listeners>
<Proxy>
<ext:AjaxProxy Url="/Example/LoadFakeRecords/" StartParam="start" LimitParam="limit" PageParam="page" SortParam="sort">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader RootProperty="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model IDProperty="ID" runat="server">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column Text="ID" DataIndex="ID" runat="server" />
<ext:Column Text="Name" DataIndex="Name" runat="server" />
</Columns>
</ColumnModel>
<BottomBar>
<ext:PagingToolbar DisplayInfo="true" runat="server" />
</BottomBar>
</ext:GridPanel>
</body>
</html>




namespace SandBox.Controllers
{
public class ExampleController : System.Web.Mvc.Controller
{
private static bool _isFirstLoad = true;

public ActionResult Index()
{
return View();
}

public StoreResult LoadFakeRecords(int start, int limit, int page, string sort)
{
List<Entity> lst = new List<Entity>();

for (int index = start; index < (page * limit); index++)
{
lst.Add(new Entity
{
ID = index,
Name = "Name" + index
});
}

StoreResult result = new StoreResult(lst, _isFirstLoad ? 100 : 200);

_isFirstLoad = false;

return result;
}
}

[Serializable]
public class Entity
{
public int ID { get; set; }

public string Name { get; set; }
}
}

RCN
Feb 04, 2015, 12:50 AM
Going further, when a record is added to or removed from store, PagingToolbar reflects the changes as expected but Store's TotalCountChange.



<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
List<Entity> lst = new List<Entity>();

for (int index = 0; index < 5; index++)
{
lst.Add(new Entity
{
ID = index,
Name = string.Format("Name - {0}", index)
});
}

this._str.DataSource = lst;
this._str.DataBind();
}
}

public class Entity
{
public int ID { get; set; }

public string Name { get; set; }
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">

<script>
var AddRecord = function () {
var recordID = App._str.getTotalCount() + 1;

App._str.add({ ID: recordID, Name: Ext.String.format('Name - {0}', recordID) });
}

var RemoveSelected = function () {
var selected = App._grd.selModel.selected.first();

if (selected != null) {
App._str.remove(selected);
}
}
</script>
</head>
<body>
<ext:ResourceManager ScriptMode="Debug" Locale="en" runat="server" />
<ext:GridPanel ID="_grd" Title="Ext.Net" Width="600" Height="350" runat="server">
<Store>
<ext:Store ID="_str" runat="server">
<Model>
<ext:Model IDProperty="ID" runat="server">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column Text="ID" DataIndex="ID" runat="server" />
<ext:Column Text="Name" DataIndex="Name" Flex="1" runat="server" />
</Columns>
</ColumnModel>
<BottomBar>
<ext:PagingToolbar runat="server" />
</BottomBar>
<Buttons>
<ext:Button Text="Add Record" runat="server">
<Listeners>
<Click Handler="AddRecord();" />
</Listeners>
</ext:Button>
<ext:Button Text="Remove Selected Record" runat="server">
<Listeners>
<Click Handler="RemoveSelected();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:GridPanel>
</body>
</html>

RCN
Feb 16, 2015, 7:53 PM
Any update regarding this issue?

fabricio.murta
Feb 17, 2015, 3:32 AM
Hello, Raphael, sorry for the delay!

In this case, no matter how I look at it, I can't see anything wrong. What did you expect between the first and second screenshots you provided?

I mean... For me it is totally fine:
1. Request data, telling I want 50 entries and I am at first page.
2. Receive data for the 50 entries telling me I have a total of 100. Then I inform the user that there are two pages, as my page size is set to 50.
3. Request data, telling I want 50 entries and I am at the second page.
4. Receive data for the 50 entries based on the page, telling me I have a total of 200 now. Then I, wisely, inform the user that there are now four pages, as my page size is set to 50 still.

I don't really get what you mean with Store's totalCount changes. The reply you changed from 100 to 200 is the total count of entries, so the pager can have an estimate of pages.

This total count for example, is the total number of rows returned by an SQL query. But as you are doing remote paging, you get only the entries you are going to show on the grid. The count, is the number of rows in total, supposed you returned all the values.

Well, then, what did I miss in the whole problem here?

RCN
Feb 17, 2015, 3:51 AM
I missed some words.

Update my original post from


On the following example, when grid page is changed, total is modified from 100 to 200. The PagingToolbar reflects the changes as expected but Store's TotalCountChange.

to


On the following example, when grid page is changed, total is modified from 100 to 200. The PagingToolbar reflects the changes as expected but Store's TotalCountChange is not fired (line 11).

Daniil
Feb 17, 2015, 1:11 PM
It looks like Sencha dropped the support of this event. I can see it in ExtJS 4, but cannot in 5.

Interesting, being with Ext.NET almost 5 years, I keep learning:) I didn't hear about the TotalCountChange event before:)

I would recommend to listen to a Store's Load event and analyze if a total count changes or not.

RCN
Feb 17, 2015, 6:13 PM
Is it gonna be dropped from Ext.NET as well?

Thank you Daniil.

Please mark this thread as closed.

fabricio.murta
Feb 17, 2015, 7:11 PM
Hello, Raphael.


Is it gonna be dropped from Ext.NET as well?


Well, as we ultimately inherit the methods from ExtJS, I am afraid we have dropped support to it in the moment we added ExtJS5 to our code base.

We could re-implement this if user demand is high enough, and we get the time and priority over other issues we already have, like fully implementing support for some new features from ExtJS..

RCN
Feb 17, 2015, 7:24 PM
We could re-implement this if user demand is high enough, and we get the time and priority over other issues we already have, like fully implementing support for some new features from ExtJS..

I agree. There is no need for that at this moment.



Is it gonna be dropped from Ext.NET as well?

It was intended for informative purposes only.

Once again, thank you.