Set specific row data
Set specific row data
dathtit
Posts: 7Questions: 0Answers: 0
Well i wan to use expression in my table. There is a column for formula and data and a column for id (and a couple of other columns). I check every cells in this col, if it contains formula, call a function to calculate. The formula is simple like this (rowID1 + rowID2 + ....). So it check the rowID and get the value of that row and do the math.
First, i was wondering where should I call the function to calculate the formula : drawCallback, initComplete or anything else.
I was trying to call that in the column render but I cannot access other row data.
Second, I have the problem with the ordering of the data :
[code]
api.column(5).data().each(function (val, index) {
api.cell(index, 5).data(calExpr(val, api, aCol));
});
[/code]
The function calExpr is the formular calculator.
If I understand it well, when I loop throught data in the formula column, calculate it and edit the cell of the row with that index.
But it all messed up. Seem like the order of the column().data() result is in different order.
And in this too. I search the id column for the row need to change and set that row data. But it still messed up.
[code]
api.column(keyCol).data().each(function (val, i) {
if (val == id) {
result = gridAPI.row(i).data()[valCol];
}
});
[/code]
I'm nearly gone mad now. Just gone through the 1.10 api manual but no result. Please give me some advices. Thanks
First, i was wondering where should I call the function to calculate the formula : drawCallback, initComplete or anything else.
I was trying to call that in the column render but I cannot access other row data.
Second, I have the problem with the ordering of the data :
[code]
api.column(5).data().each(function (val, index) {
api.cell(index, 5).data(calExpr(val, api, aCol));
});
[/code]
The function calExpr is the formular calculator.
If I understand it well, when I loop throught data in the formula column, calculate it and edit the cell of the row with that index.
But it all messed up. Seem like the order of the column().data() result is in different order.
And in this too. I search the id column for the row need to change and set that row data. But it still messed up.
[code]
api.column(keyCol).data().each(function (val, i) {
if (val == id) {
result = gridAPI.row(i).data()[valCol];
}
});
[/code]
I'm nearly gone mad now. Just gone through the 1.10 api manual but no result. Please give me some advices. Thanks
This discussion has been closed.
Replies
[code]
api.column(5,{order:'original'}).data().each(function (val, index) {
api.cell(index, 5,{order:'original'}).data(calExpr(val, api, aCol));
});
[/code]
But please some one help me with the first one. And the same issue with sparkline.
Where should I call the sparkline function.
Thanks
Allan
http://live.datatables.net/zupifis/8/edit
It worked with the drawCallback, but it must recreate the sparkline every time I change the page.