mdDataTable icon indicating copy to clipboard operation
mdDataTable copied to clipboard

How to add class or ng-class attributes to mdt-cell or mdt-column

Open faheemhameed opened this issue 7 years ago • 5 comments

Hi there,

I would like to know how to add class or ng-class attributes to mdt-cell or mdt-column. I have tried the below but the resulting <td> does not get the class. Is it intentional? I need this feature.

        <mdt-cell ng-show="currLinkObj.hasEdit && currView == 'edit'"
            class="icon-edit" html-content="true">
            <a ng-href="{{ hrefEdit | raw }}">
                <div class="text-center">
                    <md-icon class="md-primary"
                        md-svg-src="img/icons/actBtns/links/edit.svg"></md-icon>
                </div>
            </a>
        </mdt-cell>

Thanks.

faheemhameed avatar Aug 03 '16 12:08 faheemhameed

Hi @faheemhameed , thanks for your question.

It is not possible at the moment, but what you can do is to have your own content for your cells. Everything inside mdt-cell should be visible in the generated content. Try to apply your needed classes on your embedded html contents, not on the mdt-cell directive.

Is that a good solution for you?

iamisti avatar Aug 04 '16 12:08 iamisti

Hi @iamisti, thanks for your reply.

What I wanted to do is give a width for the cells manually. So I think I have set the css width to the mdt-cell or mdt-column.

any other way we can do this? For now how about inline style. Will it work?

faheemhameed avatar Aug 04 '16 12:08 faheemhameed

will not work neither. mdt-column is just collecting data, then it's a separate step when the table get's generetad with table, td, th, tr elements.

But you can set anytime a column with of a table by using :nth-child pseudo.

table td:nth-child(2) {
    width: 200px;
}

But anyway, I'll think to add a possibility to add classes to a column. It would actually make sense.

iamisti avatar Aug 04 '16 12:08 iamisti

That's a trick. Thanks!

But yes, please have the possibility to add classes to mdt-cell and mdt-column.

faheemhameed avatar Aug 04 '16 15:08 faheemhameed

having same issue. @iamisti sir any updates on adding custom class?

AdnanInayat avatar Feb 13 '17 09:02 AdnanInayat