Disable Row details icon for some rows

Disable Row details icon for some rows

hawkishhawkish Posts: 4Questions: 0Answers: 0
edited April 2015 in Free community support

I need to disable detail icon if table json data contains speacial property for a country.
Example

'data' => 
  [
    [
      'r_region' => 'Europe',
      'r_country_url' => 'spain',
    ],
[
      'r_region' => 'Europe',
      'r_country_url' => 'france',
'r_online' => 'none',
    ],
]

So here if France has r_online property I need to set some css for this icon.
I use this code for this column with icons

{
                "class":          'details-online',
                "orderable":      false,
                "data":           null,
                "defaultContent": '',
                "mRender": function ( data, type, full)  {
                    for(var k in data) {
                        if (k == 'r_online'){
                            //console.log(k, data[k],);
                            $("td.details-online").css({ color: 'red', cursor: 'default' });
                            $('td.details-online').click(function(){return false;});
                        }
                    }
                },
            },

But this code adds this css for all icons only on the first page.
Is there any solution for this?

Replies

  • hawkishhawkish Posts: 4Questions: 0Answers: 0

    I managed to solve this problem with this line of code

    '"aoColumnDefs": [ {
              "aTargets": [2],
              "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                if ( sData == "r_no" ) {
                    $(nTd).click(function(){return false;});
                    $(nTd).css('color', '#ccc').text(function(index, text) {
                        return text.replace('r_no', '');
                    });
                } else {
                    $(nTd).text(function(index, text) {
                        return text.replace('r_yes', '');
                    });
                }
              }
            }],
    

    text.replace(); function is not needed here.

This discussion has been closed.