I've read many items about Listgrid and Fieldcreator but found nothing about my problem.
I want to have a button as link in a listgrid. But not a normal url, but something a c:load and the page must be loaded in a namespace (div) and must replace the listgrid.
Until now i have something like:
<b:listGridCol dataField="Visit" label="View" width="100px" align="center">
<b:fieldCreator type="text/javascript">
var obutton = bb.document.createElementNS('http://www.w3.org/1999/xhtml', 'button');
obutton.viewNode.innerHTML = 'More info';
obutton.addEventListener('click', crLink("id=('hoofdscherm')"), false);
controller.appendChild(obutton);
return obutton;
</b:fieldCreator>
<b:fieldCreator type="text/javascript">
var obutton = bb.document.createElementNS('http://www.w3.org/1999/xhtml', 'button');
obutton.viewNode.innerHTML = 'More info';
obutton.addEventListener('click', crLink("id=('hoofdscherm')"), false);
controller.appendChild(obutton);
return obutton;
</b:fieldCreator>
In the listgrid the button with the text 'More info' is shown but the call to crlink (=function) is not executed.
Can somebody guide me to a working code.

Element creation
24 July, 2008 - 07:31 — huanhoHello,
When you create a button element, this as not been added to document, surely is not possible to add a listener in this moment. The easiest way to add a handler for the click event in your button is write html code and add trough innerHTML
An example:
<b:fieldCreator type="text/javascript">
var html = '<button onclick="crLink(document.getElementById(\'hoofdscherm\'))">More info</button>';
viewNode.innerHTML = html;
</b:fieldCreator>
fieldCreator receive the following parameters :
viewNode, controller, recordId, value
Proposed solution is not working
25 July, 2008 - 09:54 — richardreenHuando,
I've tried your code but it is not working: The button is now shown, only the text More info is shown. The link is also not working.I am using firefox 3 as browser.
wront typing
25 July, 2008 - 10:30 — richardreeni mean the button is not shown....
fieldCreator
25 July, 2008 - 11:26 — andysHi richardreen,
Try this code below
var oRow = controller.getProperty('localRecords')[recordId];
var obutton = document.createElement('button');
obutton.innerHTML = "More info";
viewNode.appendChild(obutton);
obutton.addEventListener('click',function(){alert('yes it is clicked')}, false);
return viewNode;
</b:fieldCreator>
Hope this helps,
Andys
Almost solved
25 July, 2008 - 19:42 — richardreenThanx andys, that directed me in the good direction.
Your example was working.
I changed it in the following code:
var oRow = controller.getProperty('localRecords')[recordId];
var obutton = document.createElement('button');
obutton.innerHTML = "Details";
viewNode.appendChild(obutton);
obutton.addEventListener('click',bb.command.load('videodetail.xml',"GET",recordId, null,bb.document.getElementById('hoofdscherm')), false);
return viewNode;
</b:fieldCreator>
When i load the page now it wants to load videodetail.xml for all rows in the listgrid. I only want to load after a click on the button!!
It's working
25 July, 2008 - 22:09 — richardreenFound the solutin, just put function() and take bb.command.... as the function.
Working code is:
var oRow = controller.getProperty('localRecords')[recordId];
var obutton = document.createElement('button');
obutton.innerHTML = "Details";
viewNode.appendChild(obutton);
obutton.addEventListener('click',function(){bb.command.load('videodetail.xml',"GET",recordId, null,bb.document.getElementById('hoofdscherm'))}, false);
return viewNode;
</b:fieldCreator>
Only thing left is now how to load the xml-file in the correct namespace and let it replace the listgrid.
Hi Richard, what is inside
8 August, 2008 - 13:22 — yudiHi Richard,
what is inside the videodetail.xml ? Does it have html or BTL component or XEL ? An example of XML file with html and btl component inside.
<b:tab>
<button onclick="alert('hello');">say hello</button>
</b:tab>
</b:tabBox>
~Yudi