Server Side Processing Using Returned Data To Dynamically Change td

Server Side Processing Using Returned Data To Dynamically Change td

sehrasaloni7sehrasaloni7 Posts: 2Questions: 1Answers: 0

Please bare if it is a silly question I am a newbie to js and datatables
https://ashishontech.xyz/server-side-pagination-jquery-datatable/
I am refering this article and I wish to get the data in js and use this data to dynamically change the content of the td content icludes id and a onClickFunction to be attached with datatable I am not sure How I can achieve this ?

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    The preferred method to create event handlers with Datatables is by using jQuery delegated events. Here is an example that uses columns.render to create buttons with an ID based on the row number. You can use whatever you want for the ID.

    http://live.datatables.net/qemodapi/1/edit

    Hope this helps you figure out what you want to do.

    Kevin

  • sehrasaloni7sehrasaloni7 Posts: 2Questions: 1Answers: 0

    Hi @kthorngren I wish to access the entire data for that row when I do data['plainText'][textId'] is supposed to be accessed
    My json repsone from server is like
    {
    [
    {
    "plainText":{"pid":1},

    },

    {
    "plainText":{"pid":2},

    }

    ]

    }

    Every entry in the array above is a row
    How can I achieve this

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    Thats not a valid JSON string but I'll assume its due to truncating what you are pasting. See this example for accessing nested objects.

    Kevin

This discussion has been closed.