Showing posts with label binding. Show all posts
Showing posts with label binding. Show all posts

Saturday, March 24, 2012

ListView rendering problem(Bug?)

Hi forum,

i got a problem when binding a listview against the Nortwind customers table (any table with 10 + cols). The rendering is very slow, slower than using an update panel to refresh the whole gridview.

So, i post my code and hope there is something wrong on it. Sorry for the long post, but put the initial data there was the olny way to make sure any one can just download it to a Atlas App folder and run it.

I tried to follow the examples provided, so i think the code is good, just with more cols because all the databind samples are with just a few cols. I'd like to know the opinion of the Atlas team about binding to tabular data.

<%

@dotnet.itags.org.PageLanguage="C#" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

scriptrunat="server">

</

script>

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>AtlasListView</title><styletype="text/css">div.listViewTable {font-family:Verdana,sans-serif;font-size:.9em;position:relative;}div.tableHead,div.tableBody {white-space:nowrap;overflow:visible;width:100%;}div.tableHeadspan,div.tableBodyspan {width:80px;padding:.2em;display:inline-block;border:1pxsolid#6495ED;border-top-width:0;border-bottom-width:0;}div.tableHead {background-color:#87CEFA;font-weight:bold;}div.listItemCssClass {background-color:#FFFACD;white-space:nowrap;overflow:visible;width:100%;}div.alternatingListItemCssClass {background-color:#FFFFF0;white-space:nowrap;overflow:visible;width:100%;}div.listItemCssClassspan,div.alternatingListItemCssClassspan {white-space:normal;}</style>

</

head>

<

body><formid="form1"runat="server"><atlas:ScriptManagerID="scriptManager"runat="server"></atlas:ScriptManager><h2>Customers list</h2><divid="listViewDiv"class="listViewTable"><divid="tableHeadDiv"class="tableHead"><span><aid="CustomerIDLk"href="javascript:;">CustomerID</a></span><span><aid="CompanyNameLk"href="javascript:;">CompanyName</a></span><span><aid="ContactNameLk"href="javascript:;">ContactName</a></span><span><aid="ContactTitleLk"href="javascript:;">ContactTitle</a></span><span><aid="AddressLk"href="javascript:;">Address</a></span><span><aid="CityLk"href="javascript:;">City</a></span><span><aid="RegionLk"href="javascript:;">Region</a></span><span><aid="PostalCodeLk"href="javascript:;">PostalCode</a></span><span><aid="CountryLk"href="javascript:;">Country</a></span><span><aid="PhoneLk"href="javascript:;">Phone</a></span><span><aid="FaxLk"href="javascript:;">Fax</a></span></div><divid="ListView1"class="tableBody"></div><divstyle="display: none;"><divid="ListView1_layoutTemplate"class="tableBody"><divid="ListView1_itemTemplate"><spanid="CustomerID"></span><spanid="CompanyName"></span><spanid="ContactName"></span><spanid="ContactTitle"></span><spanid="Address"></span><spanid="City"></span><spanid="Region"></span><spanid="PostalCode"></span><spanid="Country"></span><spanid="Phone"></span><spanid="Fax"></span></div></div><divid="ListView1_emptyTemplate">

No Customers records found.

</div></div></div><divid="pageNavigator"><inputtype="button"id="firstPageButton"value="<<"/><inputtype="button"id="previousPageButton"value="<"/><spanid="pageIndexLabel"></span>

/

<spanid="pageCountLabel"></span><inputtype="button"id="nextPageButton"value=">"/><inputtype="button"id="lastPageButton"value=">>"/></div></form><scripttype="text/xml-script">

<page xmlns:script=

"http://schemas.microsoft.com/xml-script/2005">

<components>

<dataSource id=

"customersDataSource" autoLoad="true">

<initialData>

<![CDATA[

new Sys.Data.DataTable(

[

new Sys.Data.DataColumn("CustomerID",String,null,false,true),new Sys.Data.DataColumn("OriginalCustomerID",String,null,false,false),new Sys.Data.DataColumn("CompanyName",String,null,false,false),new Sys.Data.DataColumn("ContactName",String,null,false,false),new Sys.Data.DataColumn("ContactTitle",String,null,false,false),new Sys.Data.DataColumn("Address",String,null,false,false),new Sys.Data.DataColumn("City",String,null,false,false),new Sys.Data.DataColumn("Region",String,null,false,false),new Sys.Data.DataColumn("PostalCode",String,null,false,false),new Sys.Data.DataColumn("Country",String,null,false,false),new Sys.Data.DataColumn("Phone",String,null,false,false),new Sys.Data.DataColumn("Fax",String,null,false,false)

],

[

{

"CustomerID":"ALFKI","OriginalCustomerID":"ALFKI","CompanyName":"Alfreds Futterkiste","ContactName":"Maria Anders","ContactTitle":"Sales Representative","Address":"Obere Str. 57","City":"Berlin","Region":{},"PostalCode":"12209","Country":"Germany","Phone":"030-0074321","Fax":"030-0076545"},

{

"CustomerID":"ANATR","OriginalCustomerID":"ANATR","CompanyName":"Ana Trujillo Emparedados y helados","ContactName":"Ana Trujillo","ContactTitle":"Owner","Address":"Avda. de la Constitución 2222","City":"México D.F.","Region":{},"PostalCode":"05021","Country":"Mexico","Phone":"(5) 555-4729","Fax":"(5) 555-3745"},

{

"CustomerID":"ANTON","OriginalCustomerID":"ANTON","CompanyName":"Antonio Moreno Taquería","ContactName":"Antonio Moreno","ContactTitle":"Owner","Address":"Mataderos 2312","City":"México D.F.","Region":{},"PostalCode":"05023","Country":"Mexico","Phone":"(5) 555-3932","Fax":{}},

{

"CustomerID":"AROUT","OriginalCustomerID":"AROUT","CompanyName":"Around the Horn","ContactName":"Thomas Hardy","ContactTitle":"Sales Representative","Address":"120 Hanover Sq.","City":"London","Region":{},"PostalCode":"WA1 1DP","Country":"UK","Phone":"(171) 555-7788","Fax":"(171) 555-6750"},

{

"CustomerID":"BERGS","OriginalCustomerID":"BERGS","CompanyName":"Berglunds snabbk?p","ContactName":"Christina Berglund","ContactTitle":"Order Administrator","Address":"Berguvsv?gen 8","City":"Lule?","Region":{},"PostalCode":"S-958 22","Country":"Sweden","Phone":"0921-12 34 65","Fax":"0921-12 34 67"},

{

"CustomerID":"BLAUS","OriginalCustomerID":"BLAUS","CompanyName":"Blauer See Delikatessen","ContactName":"Hanna Moos","ContactTitle":"Sales Representative","Address":"Forsterstr. 57","City":"Mannheim","Region":{},"PostalCode":"68306","Country":"Germany","Phone":"0621-08460","Fax":"0621-08924"},

{

"CustomerID":"BLONP","OriginalCustomerID":"BLONP","CompanyName":"Blondesddsl père et fils","ContactName":"Frédérique Citeaux","ContactTitle":"Marketing Manager","Address":"24, place Kléber","City":"Strasbourg","Region":{},"PostalCode":"67000","Country":"France","Phone":"88.60.15.31","Fax":"88.60.15.32"},

{

"CustomerID":"BOLID","OriginalCustomerID":"BOLID","CompanyName":"Bólido Comidas preparadas","ContactName":"Martín Sommer","ContactTitle":"Owner","Address":"C/ Araquil, 67","City":"Madrid","Region":{},"PostalCode":"28023","Country":"Spain","Phone":"(91) 555 22 82","Fax":"(91) 555 91 99"},

{

"CustomerID":"BONAP","OriginalCustomerID":"BONAP","CompanyName":"Bon app\'","ContactName":"Laurence Lebihan","ContactTitle":"Owner","Address":"12, rue des Bouchers","City":"Marseille","Region":{},"PostalCode":"13008","Country":"France","Phone":"91.24.45.40","Fax":"91.24.45.41"},

{

"CustomerID":"BOTTM","OriginalCustomerID":"BOTTM","CompanyName":"Bottom-Dollar Markets","ContactName":"Elizabeth Lincoln","ContactTitle":"Accounting Manager","Address":"23 Tsawassen Blvd.","City":"Tsawassen","Region":"BC","PostalCode":"T2F 8M4","Country":"Canada","Phone":"(604) 555-4729","Fax":"(604) 555-3745"},

{

"CustomerID":"BSBEV","OriginalCustomerID":"BSBEV","CompanyName":"B\'s Beverages","ContactName":"Victoria Ashworth","ContactTitle":"Sales Representative","Address":"Fauntleroy Circus","City":"London","Region":{},"PostalCode":"EC2 5NT","Country":"UK","Phone":"(171) 555-1212","Fax":{}},

{

"CustomerID":"CACTU","OriginalCustomerID":"CACTU","CompanyName":"Cactus Comidas para llevar","ContactName":"Patricio Simpson","ContactTitle":"Sales Agent","Address":"Cerrito 333","City":"Buenos Aires","Region":{},"PostalCode":"1010","Country":"Argentina","Phone":"(1) 135-5555","Fax":"(1) 135-4892"},

{

"CustomerID":"CENTC","OriginalCustomerID":"CENTC","CompanyName":"Centro comercial Moctezuma","ContactName":"Francisco Chang","ContactTitle":"Marketing Manager","Address":"Sierras de Granada 9993","City":"México D.F.","Region":{},"PostalCode":"05022","Country":"Mexico","Phone":"(5) 555-3392","Fax":"(5) 555-7293"},

{

"CustomerID":"CHOPS","OriginalCustomerID":"CHOPS","CompanyName":"Chop-suey Chinese","ContactName":"Yang Wang","ContactTitle":"Owner","Address":"Hauptstr. 29","City":"Bern","Region":{},"PostalCode":"3012","Country":"Switzerland","Phone":"0452-076545","Fax":{}},

{

"CustomerID":"COMMI","OriginalCustomerID":"COMMI","CompanyName":"Comércio Mineiro","ContactName":"Pedro Afonso","ContactTitle":"Sales Associate","Address":"Av. dos Lusíadas, 23","City":"Sao Paulo","Region":"SP","PostalCode":"05432-043","Country":"Brazil","Phone":"(11) 555-7647","Fax":{}},

{

"CustomerID":"CONSH","OriginalCustomerID":"CONSH","CompanyName":"Consolidated Holdings","ContactName":"Elizabeth Brown","ContactTitle":"Sales Representative","Address":"Berkeley Gardens 12 Brewery","City":"London","Region":{},"PostalCode":"WX1 6LT","Country":"UK","Phone":"(171) 555-2282","Fax":"(171) 555-9199"},

{

"CustomerID":"DRACD","OriginalCustomerID":"DRACD","CompanyName":"Drachenblut Delikatessen","ContactName":"Sven Ottlieb","ContactTitle":"Order Administrator","Address":"Walserweg 21","City":"Aachen","Region":{},"PostalCode":"52066","Country":"Germany","Phone":"0241-039123","Fax":"0241-059428"},

{

"CustomerID":"DUMON","OriginalCustomerID":"DUMON","CompanyName":"Du monde entier","ContactName":"Janine Labrune","ContactTitle":"Owner","Address":"67, rue des Cinquante Otages","City":"Nantes","Region":{},"PostalCode":"44000","Country":"France","Phone":"40.67.88.88","Fax":"40.67.89.89"},

{

"CustomerID":"EASTC","OriginalCustomerID":"EASTC","CompanyName":"Eastern Connection","ContactName":"Ann Devon","ContactTitle":"Sales Agent","Address":"35 King George","City":"London","Region":{},"PostalCode":"WX3 6FW","Country":"UK","Phone":"(171) 555-0297","Fax":"(171) 555-3373"},

{

"CustomerID":"ERNSH","OriginalCustomerID":"ERNSH","CompanyName":"Ernst Handel","ContactName":"Roland Mendel","ContactTitle":"Sales Manager","Address":"Kirchgasse 6","City":"Graz","Region":{},"PostalCode":"8010","Country":"Austria","Phone":"7675-3425","Fax":"7675-3426"},

{

"CustomerID":"FAMIA","OriginalCustomerID":"FAMIA","CompanyName":"Familia Arquibaldo","ContactName":"Aria Cruz","ContactTitle":"Marketing Assistant","Address":"Rua Orós, 92","City":"Sao Paulo","Region":"SP","PostalCode":"05442-030","Country":"Brazil","Phone":"(11) 555-9857","Fax":{}},

{

"CustomerID":"FISSA","OriginalCustomerID":"FISSA","CompanyName":"FISSA Fabrica Inter. Salchichas S.A.","ContactName":"Diego Roel","ContactTitle":"Accounting Manager","Address":"C/ Moralzarzal, 86","City":"Madrid","Region":{},"PostalCode":"28034","Country":"Spain","Phone":"(91) 555 94 44","Fax":"(91) 555 55 93"},

{

"CustomerID":"FOLIG","OriginalCustomerID":"FOLIG","CompanyName":"Folies gourmandes","ContactName":"Martine Rancé","ContactTitle":"Assistant Sales Agent","Address":"184, chaussée de Tournai","City":"Lille","Region":{},"PostalCode":"59000","Country":"France","Phone":"20.16.10.16","Fax":"20.16.10.17"},

{

"CustomerID":"FOLKO","OriginalCustomerID":"FOLKO","CompanyName":"Folk och f? HB","ContactName":"Maria Larsson","ContactTitle":"Owner","Address":"?kergatan 24","City":"Br?cke","Region":{},"PostalCode":"S-844 67","Country":"Sweden","Phone":"0695-34 67 21","Fax":{}},

{

"CustomerID":"FRANK","OriginalCustomerID":"FRANK","CompanyName":"Frankenversand","ContactName":"Peter Franken","ContactTitle":"Marketing Manager","Address":"Berliner Platz 43","City":"München","Region":{},"PostalCode":"80805","Country":"Germany","Phone":"089-0877310","Fax":"089-0877451"},

{

"CustomerID":"FRANR","OriginalCustomerID":"FRANR","CompanyName":"France restauration","ContactName":"Carine Schmitt","ContactTitle":"Marketing Manager","Address":"54, rue Royale","City":"Nantes","Region":{},"PostalCode":"44000","Country":"France","Phone":"40.32.21.21","Fax":"40.32.21.20"}

]

)

]]>

</initialData>

</dataSource>

<listView id=

"ListView1" itemCssClass="listItemCssClass"

itemTemplateParentElementId=

"ListView1_layoutTemplate"

alternatingItemCssClass=

"alternatingListItemCssClass">

<bindings>

<binding dataContext=

"view" dataPath="filteredData"

property=

"data"/>

</bindings>

<layoutTemplate>

<template layoutElement=

"ListView1_layoutTemplate"/>

</layoutTemplate>

<itemTemplate>

<template layoutElement=

"ListView1_itemTemplate">

<label id=

"CustomerID">

<bindings>

<binding dataPath=

"CustomerID" property="text"/>

</bindings>

</label>

<label id=

"CompanyName">

<bindings>

<binding dataPath=

"CompanyName" property="text"/>

</bindings>

</label>

<label id=

"ContactName">

<bindings>

<binding dataPath=

"ContactName" property="text"/>

</bindings>

</label>

<label id=

"ContactTitle">

<bindings>

<binding dataPath=

"ContactTitle" property="text"/>

</bindings>

</label>

<label id=

"Address">

<bindings>

<binding dataPath=

"Address" property="text"/>

</bindings>

</label>

<label id=

"Region">

<bindings>

<binding dataPath=

"Region" property="text"/>

</bindings>

</label>

<label id=

"PostalCode">

<bindings>

<binding dataPath=

"PostalCode" property="text"/>

</bindings>

</label>

<label id=

"Country">

<bindings>

<binding dataPath=

"Country" property="text"/>

</bindings>

</label>

<label id=

"Phone">

<bindings>

<binding dataPath=

"Phone" property="text"/>

</bindings>

</label>

<label id=

"Fax">

<bindings>

<binding dataPath=

"Fax" property="text"/>

</bindings>

</label>

</template>

</itemTemplate>

<emptyTemplate>

<template layoutElement=

"ListView1_emptyTemplate" />

</emptyTemplate>

</listView>

<dataView id=

"view" pageSize="10">

<bindings>

<binding dataContext=

"customersDataSource"

dataPath=

"data" property="data" />

</bindings>

</dataView>

<dataNavigator id=

"pageNavigator" dataView="view"/>

<button id=

"previousPageButton" parent="pageNavigator" command="previousPage">

<bindings>

<binding property=

"enabled" dataPath="hasPreviousPage"/>

</bindings>

</button>

<label id=

"pageIndexLabel" parent="pageNavigator">

<bindings>

<binding property=

"text" dataPath="pageIndex" transform="Add"/>

</bindings>

</label>

<label id=

"pageCountLabel" parent="pageNavigator">

<bindings>

<binding property=

"text" dataPath="pageCount"/>

</bindings>

</label>

<button id=

"nextPageButton" parent="pageNavigator" command="nextPAGE">

<bindings>

<binding property=

"enabled" dataPath="hasNextPage"/>

</bindings>

</button>

<button id=

"firstPageButton" parent="pageNavigator" command="FIRSTPage">

</button>

<button id=

"lastPageButton" parent="pageNavigator" command="lastpage">

</button>

</components>

</page>

</script>

</

body>

</

html>

hello.

well, i wouldn't say that it's a lot slower...i'd say that with listview you're seeing it being rendered as it's being generated (though in my machine it looks like it's rendering 4 rows at a time). when you use the panel, everything is replaced at once and i think that is why you don't seen it being rendered...


Hi Luis,

in a normal sample you would have to add the time to retrieve the data.

Here render 5 rows at a time by design, but just to render 5 rows take longer than the update panel to connect to the server and render the 10 rows. you call that not slow.

i think the problem it′s with the templates, if you override the render method of the listview control and build table dinamically, it works like a champ.

what make me suspicious is the lack of any information regarding tabular data and tables in the Atlas docs, also there is not substitute for the gridview control what is the most important ASP.NET databound control.

Please, can some one in the Atlas team explain the plans about this matter


hello again.

hum...interesting...the only thing i'm seeing here is that it renders 4 rows at a time, but those 4 rows are rendered as a block (ie, they all appear at the same time). that's why i said it wasn't slow...

ListView, dataContext, and Actions

I'm working with the (client-side) Atlas ListView control, and seeing some behavior I didn't expect. The code is binding the ListView to an XmlDataSource, with item templates that use XPathBindings to populate hyperlinks, labels, etc. The basic stuff works - for example, there's an anchor in the markup with a corresponding Hyperlink component in the XML Script, and using the XpathBinding to populate the Hyperlink text works great.

However, the other thing I'm trying to do is to wire up the click event to a SetPropertyAction, and set properties on the SetPropertyAction using XPathBinding to the same listview data item that the Hyperlink is bound to. That doesn't seem to be working. My general impression is that the dataContext for a component is supposed to be inherited from its parent if it isn't set explicitly on that component. I assumed that would carry over to the action, so the context for bindings on the action would be the ListView item. That doesn't seem to be the case.

Looking at the Atlas code, it seems that an Action always returns itself as its data context. Is there a reason for that? Is there some other way of accomplishing what I'm trying to do?

Kevin

OK, I found a blog post that explains why the dataContext on the Action is set to the action itself, and how to address that. Unfortunately, I'm now running in the problem that I reported before about bindings on Actions. Since Actions always evaluate both the In and Out directions of bindings, they are incompatible with XPathBindings (which throw an error in the evaluateOut call). I think there's a bit of a design problem in this part of Atlas.