How to fetch id form json array and assign it to url of edit.php

How to fetch id form json array and assign it to url of edit.php

bhatt_axaybhatt_axay Posts: 46Questions: 12Answers: 3

Hello,

I am very near to find the solution but how to fetch id from json array and assign it

<a href="edit.php?edt_id="+id>Edit</a>

The code is mentioned below:

columns: [
{ data: "id" },

        { data: "fullname" },

        { data: "user_name" },

        { data: "phnumber" },
        { data: "address"},
        {
            data: null, 
            className: "center",

            defaultContent: '<a href="edit.php?edt_id="+id  class="">Edit</a>           
        }
    ]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,262Questions: 1Answers: 10,424 Site admin

    Use columns.render if you need to assign a dynamic value.

    Allan

  • bhatt_axaybhatt_axay Posts: 46Questions: 12Answers: 3

    Hello allan

    Above answer is right but in my case i'm using the value of returning json array and i want to use it as mentioned in above code.

  • allanallan Posts: 63,262Questions: 1Answers: 10,424 Site admin
    Answer ✓

    I'm not sure I understand the problem. Why would you not be able to use colums.render to do what you need? It sounds like exactly what you want. Use it as a function. The documentation shows examples of how it can be used like that.

    Allan

  • bhatt_axaybhatt_axay Posts: 46Questions: 12Answers: 3

    okk I got it.

    Thank you so much

  • bhatt_axaybhatt_axay Posts: 46Questions: 12Answers: 3

    Hello,

    Still i got the error in columns.render I can't get my id from my json array. Below is my code:

    "columnDefs" : [{
    "data": "id",
    "defaultContent": "<a href=edit.php?id="+{data : id}+">Edit</a>",
    "target" : [ 7 ]// can be null or undefined
    }]

  • bhatt_axaybhatt_axay Posts: 46Questions: 12Answers: 3

    Okk I got the answer finally.

This discussion has been closed.