DT 1.10 Render cells

DT 1.10 Render cells

deliatordeliator Posts: 95Questions: 1Answers: 0

HI,

http://live.datatables.net/cixitino/1/

I don't understand why the value of the first column/second row is not render in red...

Any idea ?

Thx

Marc

Replies

  • Loren MaxwellLoren Maxwell Posts: 406Questions: 99Answers: 10

    Hey Marc, it's in red for me.

  • allanallan Posts: 63,414Questions: 1Answers: 10,454 Site admin

    Looks like you might have edited the page since the original post - the HTML for the body row in the table isn't valid.

    Allan

  • deliatordeliator Posts: 95Questions: 1Answers: 0
    edited October 2018
  • deliatordeliator Posts: 95Questions: 1Answers: 0

    I have exaclty the same code in my page but value don't appear in red ...
    The only thing that changed si that i work server side ...

    Any idea ?

  • kthorngrenkthorngren Posts: 21,284Questions: 26Answers: 4,940

    If the example is working but your site is not then without seeing it its hard to diagnose. I would suggest using console.log statements in your columns.render function to output the variables and to see if the if statement is ever true and setting the red style. From there you can determine whether to troubleshoot a styling issue or an issue with your if statement.

    Kevin

  • deliatordeliator Posts: 95Questions: 1Answers: 0

    console.log in the sandbox gives me the exact values
    http://live.datatables.net/wozuyana/3/

    when i add the same console.log(row[2]); in my page it returns me an undefined value.

  • kthorngrenkthorngren Posts: 21,284Questions: 26Answers: 4,940

    when i add the same console.log(row[2]); in my page it returns me an undefined value.

    Are you using columns.data to define your columns? If so then you need to access the row data as an object not an array.

    Kevin

  • deliatordeliator Posts: 95Questions: 1Answers: 0
    edited October 2018

    Yes i use columns.data ...

    How can I access the row data as an object ?
    Can you give me an example ?

    Thank you

  • kthorngrenkthorngren Posts: 21,284Questions: 26Answers: 4,940

    If you have this for example:

            "columns": [
                { "data": "name" },
                { "data": "position" },
                { "data": "office" },
                { "data": "extn" },
                { "data": "start_date" },
                { "data": "salary" }
            ]
    

    And you wanted the data in the office column you would use row.office in your render function.

    Kevin

  • deliatordeliator Posts: 95Questions: 1Answers: 0

    Great Kevin, it works fine now :-)
    you take away a thorn from my feet ;-)

    Thanks again.

    Marc

This discussion has been closed.