columns data, get data from specific calculated td value

columns data, get data from specific calculated td value

bilusesbiluses Posts: 26Questions: 10Answers: 0

i have this
columns: [
{ data: "advertisers.id_am" },
{ data: "incomes.clicks" },
{ // TOTAL FACT.
data: null, render: function ( data, type, row ) {
var total_fact = +data[8] + +data.incomes.accumulated;
return total_fact;
}
} ]

data[8] is the value for field VALIDATED
i'm getting a NaN value right now.
that data[8] is a calculated from other values, it is not saved in data.incomes.validated ( in that case i have already the solution)

how can i get that data[8] value??

thanks

Answers

  • kthorngrenkthorngren Posts: 21,304Questions: 26Answers: 4,947

    Looks like your data is object based not array based and you are trying to access the value as an array: data[8]. Its unclear to me from your description what object data[8] is. Sounds like it should be data.incomes.validated but you indicate its not.

    You will need to change data[8] to point to the object with that value.

    Kevin

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Could you clarify why you've marked Kevin's answer as rejected please? It is basically exactly what I would have said as well.

    Allan

  • bilusesbiluses Posts: 26Questions: 10Answers: 0
    edited September 2017

    in other words, the a current <td> value for that calculated column

  • bilusesbiluses Posts: 26Questions: 10Answers: 0

    Kevin's said the same as i said, that's why i reject answer.

    Thing is that i need to get the <td> value, because it's calculated and dinamic value.
    i can't data.incomes.validated becuse it's NULL and data[8] gives a [Object object]

    please help

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    I would have expected data[8] to give undefined since the data source appears to be an object, not an array.

    But really we'd need either a test case or at least a debug trace to understand the data object.

    Allan

  • bilusesbiluses Posts: 26Questions: 10Answers: 0

    maybe $('td', currentRow).eq(8).text() ??

  • bilusesbiluses Posts: 26Questions: 10Answers: 0

    i end up with a solution:
    var modifier = editor.modifier();
    var currentRow = table.row(modifier).node();
    return $('td', currentRow).eq(8).text();

    that is

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    You are using the editor variable inside a rendering function? That would only work if Editor has been put into an edit mode. Otherwise it will just return null.

    Allan

  • abdihahiabdihahi Posts: 1Questions: 0Answers: 0

    ****

This discussion has been closed.