How to get query results in manually created column

How to get query results in manually created column

athanasiusathanasius Posts: 33Questions: 3Answers: 0

We need the first column of a server side call to be a clickable button to edit the record.

I built the button in the column section which doesn't allow for dynamic data (as far as I can tell) so I can't get the record id in the url. I also read through the columnDefs functionality, but the buttonURL needs to be encrypted so I'm not sure if I can use this either.

    <cfset buttonURL = urlEncodedFormat(encryptFunction.getEncrypt (encryptFunction~~~~,"id=#result.id#&s=#Now()#"))>
    <cfsavecontent variable="JsonObject">
        {"draw": <cfoutput>#val(arguments.draw)#</cfoutput>,
        "recordsTotal": <cfoutput>#recordsTotal#</cfoutput>,
        "recordsFiltered": <cfoutput>#result.recordCount#</cfoutput>,
        "columns": [
            {
                "title": "Tools",
                "class": "actions",
                "data": "null",
                "defaultContent": "<button type='button' title='Edit' class='editRecord' buttonURL=<cfoutput>'#buttonURL#'</cfoutput>>Edit</button>"
            }

Answers

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

    If you want to use row data to build the buttons then use columns.render, like this example:
    http://live.datatables.net/qemodapi/1/edit

    Kevin

  • athanasiusathanasius Posts: 33Questions: 3Answers: 0

    Thank you.

    The issue here is that the button data needs to be encrypted, which has to be done server side, not in the js. If I can use columnDefs in the json I build server side to send back to the ajax call, that might work.

Sign In or Register to comment.