Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
jmoukel
Posts: 111
Registered: ‎07-05-2012
My Device: none
My Carrier: MOvistar
Accepted Solution

BB10: Can't Create GridList Dynamically in bbui

Hi guys,

 

I've struggling a lot with this issue. I apreciate any help possible.

 

I'm trying to add a Grid List dynamically in bbui. This is my code: 

// Getting grid list
var grid = document.getElementById('multimedia');
		  
// Create group
var group = document.createElement('div');
group.setAttribute('data-bb-type','group');
grid.appendChild(group);		
		
// Create row 0
var row = document.createElement('div');
row.setAttribute('data-bb-type','row');
group.appendChild(row);
		
for(var i=1; i<3; i++) 
{
	var item = document.createElement('div');
	item.setAttribute('data-bb-type', 'item');
	item.setAttribute('data-bb-img', listaNoticiasGeneral.listanoticias[i+secCreatGrid][3][0].imagenUrl);
	item.setAttribute('data-bb-title', listaNoticiasGeneral.listanoticias[i+secCreatGrid][0]);
	item.setAttribute('onclick',"bb.pushScreen(\'multimedia_d.html\',\'multimedia_d\',{\'id\':\''+(i+secCreatGrid)+'\',\'tipo\':\'noticias\',\'i\':\''+(i+secCreatGrid)+'\'});");
	item.innerHTML = 'World';
	row.appendChild(item);
}
		
// Create row 0
var row2 = document.createElement('div');
row2.setAttribute('data-bb-type','row');
group.appendChild(row2);
		
for(var i=3; i<5; i++) 
{
	var item = document.createElement('div');
	item.setAttribute('data-bb-type', 'item');
	item.setAttribute('data-bb-img', listaNoticiasGeneral.listanoticias[i+secCreatGrid][3][0].imagenUrl);
	item.setAttribute('data-bb-title', listaNoticiasGeneral.listanoticias[i+secCreatGrid][0]);
	item.setAttribute('onclick',"bb.pushScreen(\'multimedia_d.html\',\'multimedia_d\',{\'id\':\''+(i+secCreatGrid)+'\',\'tipo\':\'noticias\',\'i\':\''+(i+secCreatGrid)+'\'});");
	item.innerHTML = 'World';
	row2.appendChild(item);
}
		
grid = bb.grid.style(grid);
		
document.getElementById('multimedia').appendChild(grid);	

 

The problem is that is doesn't create the grid. I recieve an error: "Uncaught TypeError: Object # has no method 'style'".

 

It used to work in the previous versions of bbui, but not anymore.

 

Any ideas about it?

 

Thanks a lot everyone!

Please use plain text.
BlackBerry Development Advisor (Retired)
grahamzibar
Posts: 71
Registered: ‎09-19-2012
My Device: No sleep til BlackBerry 10
My Carrier: Bell

Re: BB10: Can't Create GridList Dynamically in bbui

Looking through the bbui.js source code suggests only an apply method exists on the bb.grid object.  Did you try that method?

------------------------------
@grahamzibar
-_- zZZ
Please use plain text.
BlackBerry Development Advisor
rcraigbarnes
Posts: 40
Registered: ‎01-11-2013
My Device: BlackBerry Z10
My Carrier: Rogers

Re: BB10: Can't Create GridList Dynamically in bbui

Dynamic gridLists aren't yet supported (https://github.com/blackberry/bbUI.js/issues/312) it is being worked on, but not ready for the limelight yet.

 

You can fake it by loading your GridList ondomready and letting bbUI style it, but once the screen is rendered there is no way (currently) to create or update.

--
Website Relations - Web Technologies

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
Please use plain text.
BlackBerry Development Advisor (Retired)
grahamzibar
Posts: 71
Registered: ‎09-19-2012
My Device: No sleep til BlackBerry 10
My Carrier: Bell

Re: BB10: Can't Create GridList Dynamically in bbui

Thanks, Rory!  Looks like I should pay more attention to BBUI development :smileywink:

------------------------------
@grahamzibar
-_- zZZ
Please use plain text.
Developer
jmoukel
Posts: 111
Registered: ‎07-05-2012
My Device: none
My Carrier: MOvistar

Re: BB10: Can't Create GridList Dynamically in bbui

Thanks for your help rcraigbarnes!

I'm calling my function "fillTheGrid" from ondomready. The problem is that this function also calls getJSON function to get a remote json which contains the content I'm going to fill the grid with.

Because this getJSON function is asynchronous, by the time it receives the json and starts fillinf the grid with it, the ondomready function has stopped executing.

Any ideas?

Thanks!
Please use plain text.
Developer
jmoukel
Posts: 111
Registered: ‎07-05-2012
My Device: none
My Carrier: MOvistar

Re: BB10: Can't Create GridList Dynamically in bbui

I solved it! With this line:

setTimeout(bb.domready.fire, 1);

At the end of the "createGrid", I just added that line. It is a call to the ondomready function.
Please use plain text.