Veshraj Joshi
Veshraj Joshi

Reputation: 3579

make rows font color seem like inactive and active on grid view of yii2 and twig template?

I have records with the flag of active and inactive, want to so render rows differently for inactive records. I got some ideas about rowOptions in grid view -

{{ grid_view_widget({
    'id': 'company-roles',
    'tableOptions': { 'class':  'table table-hover'},
    'layout': '<div class=\"table-responsive\">{items}</div>{summary}<div class=\"pull-right\">{pager}</div>',
    'dataProvider': rolesDataProvider,
    'sorter': null,
    'rowOptions': {'style':(inaktiv)?'color:#acacac;':''},
    'columns': [
    {
        'attribute': 'tittel',
        'label': 'Role',
        'enableSorting': false,
    }, 
    .
    .
    ]
});
}}

and when i tried closure function(model, key, index, grid){} inside rowOptions it provide an error - Unknown "function" function in "_contactperson.twig" at line 23. and $ also not supported in twig

what i want is - if record is inactive then change the text color of that record

Upvotes: 0

Views: 403

Answers (1)

Alex
Alex

Reputation: 448

If you are not bound to Yii2 Grid, Kartik Gridview supports this out of the box:

http://demos.krajee.com/grid-demo

Upvotes: 1

Related Questions