问题描述:

I have a datatable populated by 4 fields via a Laravel route. That is fine and works great.

Additionally I have added 2 columns with icons, again that is fine. One is to show a sliding panel of information and one will be a link to more details.

I show these by rendering column info.

I wish to have an onlick event for one which will use the data in column 0 which is a key field. I have tried:

{

"targets": [4],

"render": function ( data, type, full, meta ) {

{return '<div align="center"><a href="#"><img src="{{ asset("siteicons/Info_Box_Blue.png") }}" id="trigger" onclick="ShowSlider( {{ ' + 0 + '}} )"></a></div>';}

}

},

This is in the columnDefs, but clicking does not do anything - even if I put a simple alert.

Help, please!

网友答案:
"render": function ( data, type, full, meta ) {
    return '<div align="center"><a href="#"><img src="{{ asset("siteicons/Info_Box_Blue.png") }}" id="trigger" onclick="ShowSlider(' + full[0] + ')"></a></div>';   
}

If you're trying to get data from the row add it like this.

网友答案:

Extra curly braces are there in your render function. Could u please remove and try it ?

"render": function ( data, type, full, meta ) {
            return '<div align="center"><a href="#"><img src="{{ asset("siteicons/Info_Box_Blue.png") }}" id="trigger" onclick="ShowSlider(0)"></a></div>';   
                                }
相关阅读:
Top