Opened 11 years ago

Closed 3 years ago

#8199 closed defect (patchwelcome)

[dojox.layout] ScrollPane doesn't layout properly when containing dynamic contents

Reported by: stimy Owned by: dante
Priority: high Milestone: 1.13
Component: DojoX Layout Version: 1.2.1
Keywords: dojox layout ScrollPane Cc:
Blocked By: Blocking:

Description

I've created a news widget that reads json data and is contained inside a dojox.layout.ScrollPane?. When initially loaded, the ScrollPane? isn't scrolling. The workaround I've found is to call layout() on the "_enter" event. That way, everytime the mouse enters the widget, it gets "layouted" again. Here is my code :

<!-- News Widget -->
<div dojoType="dijit.Declaration" widgetClass="News"
        	defaults="{store: 'store'}">
    <div dojoAttachPoint="newsNode"></div>
    <script type="dojo/method" >
		this.getAllNews = function() {
			var store = new dojo.data.ItemFileWriteStore({url : this.store});
			var newsNode = this.newsNode;					
			store.fetch({
				onBegin : function() {
				},
				onError : function(errData, request) {
					console.debug("Error while retrieving news");
					console.dir(errData);
				},
				onItem : function(item) {
					if (!store.hasAttribute(item, "endOfFile")) {
						// Titre
						var newsTitle = store.getValue(item, "newstitle");
						var titleNode = document.createElement("div");
						dojo.addClass(titleNode, "newsTitle");
						titleNode.innerHTML = newsTitle;
						// Date
						var newsDate = store.getValue(item, "newsdate");
						var dateNode = document.createElement("div");
						dojo.addClass(dateNode, "newsDate");
						dateNode.innerHTML = newsDate;
						// Text
						var newsText = store.getValue(item, "news");
						var textNode = document.createElement("div");
						dojo.addClass(textNode, "newsBody");
						textNode.innerHTML = newsText;	
						// Picture
						var newsMedia = store.getValue(item, "media");
						var mediaNode = document.createElement("div");
						dojo.addClass(mediaNode, "newsMedia");
						mediaNode.innerHTML = "<img src=\"img/" + newsMedia + "\" width=\"452px\"/>";
								dojo.place(titleNode, newsNode, "last");
						dojo.place(dateNode, newsNode, "last");
						dojo.place(textNode, newsNode, "last");
						dojo.place(mediaNode, newsNode, "last");
					}
				},
				
				onComplete : function(items, request) {		
				}
			});
		}
		this.getAllNews();
	</script>
</div>
   
<!-- Display -->
<div id="altStyle">
	<div id="scrollPane" dojoType="dojox.layout.ScrollPane" preventCache="true" style="width:470px; height:500px; padding-left:12px">
    	<script type="dojo/connect" event="_enter">
		this.layout();
	</script>
    	<!-- call the news widget declared above -->
        <div dojoType="News" store="ws/getNews.php"/>
	</div>
</div>

And here is some json to test the widget...

{	"id" : "id",
	"label": "title", 
	"items": [
		{
			"id": 1, 
			"title": "News 1", 
			"date": "21/11/2008",
			"text": "Some news.",
			"media": "img/mypicture1.jpg"
		},
		{
			"id": 2, 
			"title": "News 2", 
			"date": "21/11/2008",
			"text": "Some news.",
			"media": "img/mypicture2.jpg"
		},
		{
			"id": 1, 
			"title": "News 3", 
			"date": "21/11/2008",
			"text": "Some news.",
			"media": "img/mypicture3.jpg"
		}
	]
}

Change History (6)

comment:1 Changed 11 years ago by bill

Component: GeneralDojox
Owner: changed from anonymous to Adam Peller

comment:2 Changed 11 years ago by Adam Peller

Owner: changed from Adam Peller to dante

comment:3 Changed 10 years ago by dante

Milestone: tbd1.4
Summary: dojox.layout.ScrollPane doesn't layout properly when containing dynamic contents[dojox.layout] ScrollPane doesn't layout properly when containing dynamic contents

calling layout that often probably isn't the best thing. there is something else wonky going on with scrollpane at the moment, will look for 1.4 hopefully.

comment:4 Changed 10 years ago by dante

Milestone: 1.4future

comment:5 Changed 9 years ago by bill

Component: DojoxDojoX Layout

comment:6 Changed 3 years ago by dylan

Milestone: future1.12
Resolution: patchwelcome
Status: newclosed

Given that no one has shown interest in creating a patch in the past 5+ years, I'm closing this as patchwelcome.

Note: See TracTickets for help on using tickets.