Update the data before viewing the tables

Update the data before viewing the tables

kali83kali83 Posts: 18Questions: 0Answers: 0
edited April 2021 in DataTables 1.10

Hi,
I would need to update a negative value. For example my data is -10, i delete the "-", i color the line in red and the displayed data must be 10.
So i should update the json which returns me the php.

This is my code:

"rowCallback": function( row, data ) {
                        if ((data.imp < 0 && data.iuv != '') || data.st == 'D') {
                            $('td', row).css( 'background-color', '#ff6347' );
                            var val = data.imp.substr(1);
                            console.log(val);
                        }else if ((data.imp > 0 && data.iuv != '') || data.st == 'M'){
                            $('td', row).css( 'background-color', '#FBB917' );
                        }else if ((data.imp > 0 && data.iuv == '') || data.st == 'N'){
                            $('td', row).css( 'background-color', '#3cb371' );
                        }
                      },

How can i do?

I have read online .... but i have not found anything that was useful for me!

Thanks

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Use Orthogonal data with columns.render. For the display type manipulate the number to display as you like.

    Kevin

  • kali83kali83 Posts: 18Questions: 0Answers: 0

    Thank you!

    It works....

    Daniel

  • kali83kali83 Posts: 18Questions: 0Answers: 0

    I have another question...

    This is my JSON:

    "data": {"id": "548923", "coduser": 53443....}
    "recordsFiltered": 175
    "recordsTotal": 175
    "addinfo": "LOCK"

    If i wanted to display the addinfo not in the table, how can i give?

    Thanks...

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    You can use ajax.json() to get the JSON response.

    Kevin

  • kali83kali83 Posts: 18Questions: 0Answers: 0

    Thank you!

    It works....

This discussion has been closed.