Feb 27, 2014, 7:40 AM
[CLOSED] Paging Toolbars on DataViews
I've been unable to get a Paging Toolbar to work properly with DataViews. In short the e.Total is not being calculated by the toolbar. I do get the e.Start and e.Limit. However, the PagingToolbar thinks that the limit is the count.
I rebuilt into a very simple example.
Codebehind
Markup
I rebuilt into a very simple example.
Codebehind
namespace TestExt
{
public partial class Default : System.Web.UI.Page
{
private string[] names =
@"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"
.Replace(",", "").Replace(" ", " ").Split(' ');
protected void Page_Load(object sender, EventArgs e)
{
}
// FIRST TRY
protected void DocList_Refresh(object sender, StoreReadDataEventArgs e)
{
if (X.IsAjaxRequest)
{
List<sample> foobar = new List<sample>();
for (int i = 0; i < 50; i++)
foobar.Add(new sample() { Date = DateTime.Now.AddDays(i), Id = i, Name = names[i] });
e.Total = foobar.Count();
this.StoreDocumentList.DataSource = foobar.Skip(e.Start).Take(e.Limit);
this.StoreDocumentList.DataBind();
}
}
// SECOND TRY
[DirectMethod]
public object BindData(string action, Dictionary<string, object> extraParams)
{
var iStart = 0;
var iLimit = 10;
if (extraParams != null)
{
StoreRequestParameters prms = new StoreRequestParameters(extraParams);
iStart = prms.Start;
iLimit = prms.Limit;
}
List<sample> foobar = new List<sample>();
for (int i = 0; i < 50; i++)
foobar.Add(new sample() { Date = DateTime.Now.AddDays(i), Id = i, Name = names[i] });
return foobar.Skip(iStart).Take(iLimit);
}
}
public class sample
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime Date { get; set; }
}
}
Markup
<form id="form1" runat="server">
<ext:resourcemanager runat="server">
</ext:resourcemanager>
<ext:Panel runat="server" ID="pnl1">
<Items>
<ext:Hidden ID="HiddenPersonId" runat="server">
</ext:Hidden>
<ext:DataView ID="dvDocumentList"
runat="server"
DisableSelection="true"
ItemSelector="tr.customer-record">
<Store>
<ext:Store ID="StoreDocumentList" runat="server" IDMode="Static" PageSize="10" OnReadData="DocList_Refresh">
<%-- <Proxy>
<ext:PageProxy DirectFn="App.direct.BindData" />
</Proxy>--%>
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="FileName" />
<ext:ModelField Name="Date" DateFormat="mm/dd/YYYY" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Tpl ID="Tpl1" runat="server">
<Html>
<div>
<table class="tbl">
<tpl for=".">
<tr class="customer-record">
<td>
<label>Record {Id}</label>
<br />
<b>
<label>{FileName}</label>
</b>
<p />
<label>{Date}</label>
</td>
</tr>
</tpl>
</table>
</div>
</Html>
</Tpl>
</ext:DataView>
</Items>
<TopBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="StoreDocumentList" HideRefresh="false">
</ext:PagingToolbar>
</TopBar>
</ext:Panel>
</form>
Last edited by Daniil; Mar 11, 2014 at 6:38 AM.
Reason: [CLOSED]