3.0.0

Buttons on every row in a grid

I made a simple data grid and want to place an edit
button on every rows last cell. Is this possible?

To make it tricky for you: we are using the "smarty" template system.

Details:
{foreach name=todo from=$todo item=todoItem}
grid.addRow({$todoItem.id});
grid.setCellText(["{$todoItem.id}",
"Cell1 value",
"Cell2 value",
...
"<span id='cmdEdit{$todoItem.id}'></span>"
{$todoItem.id});

{/foreach}

{foreach name=todo from=$todo item=todoItem}
var cmdEdit{$todoItem.id} = new AW.UI.Button;
cmdEdit{$todoItem.id}.setId("cmdEdit{$todoItem.id}");
cmdEdit{$todoItem.id}.setControlText("Edit");
cmdEdit{$todoItem.id}.setControlImage("Edit");
cmdEdit{$todoItem.id}.refresh();
{/foreach}

Any hints?

Tilmann
Tilmann Starke (Softwork Germany)
May 3,
Sorry, I don't have any experience with Smarty. Your code looks reasonable, does it actually work like that?
Alex (ActiveWidgets)
May 4,
Hi,

I use smarty a lot and on a quick glance at your template, it looks fine.
If you are having problems, here are a few tips that I use when working with smarty:

1) Try adding {debug} to the top of your smarty template. This will give you a popup window with all the variables and their values that have been passed to the template. This is to figure out if your php script is sending an incorrect value or you are using it incorrectly in the template.

2) In FireFox, use Tools > Error Console to catch obvious javascript errors, or better still, install the FireBug extension (http://www.getfirebug.com/). When using smarty variables in javascript, I often end up making simple mistakes that cause a javascript syntax error.

3) Finally, view source of the page to ensure your template is producing the code you want it to produce.

If you are still having problems after that, can you post a sample php script that calls the template ? I can try it out and see if I catch anything.

PS: Is the array given as parameter to grid.setCellText() closed properly ? That is, does the [ have a matching ] in your template ?
Ankur Motreja
May 4,
Alex and Ankur,

Thanks for respond.
I will try out some more and give you
information about the results.

Tilmann

Tilmann Starke
May 7,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.