Mateusz Lewandowski
2016-10-05 07:47:21 UTC
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table load
on the html page.
This is my code:
Future LoadData() async
{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0;
var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++;
});
tableDiv.nodes.add(table);
querySelector("#Content").setInnerHtml(tableDiv.outerHtml);
}
void LoadDetails(var id)
{
print("test "+id);
}
Have you any idea how to solve this problem?
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table load
on the html page.
This is my code:
Future LoadData() async
{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0;
var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++;
});
tableDiv.nodes.add(table);
querySelector("#Content").setInnerHtml(tableDiv.outerHtml);
}
void LoadDetails(var id)
{
print("test "+id);
}
Have you any idea how to solve this problem?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.