mdDataTable icon indicating copy to clipboard operation
mdDataTable copied to clipboard

md-custom-cell not display md-button inside

Open netanelwebzi opened this issue 9 years ago • 11 comments

Hey ,

That's my html code: http://pastebin.com/cRnZm7jY

on md-custom-cell element I trying to insert md-button for actions like: edit, delete. for some reason I cant see the buttons on the table.

Someone ?

netanelwebzi avatar Sep 01 '16 10:09 netanelwebzi

Sorry for my English, because I'm brazilian. So I decided:

Example:

<mdt-row ng-repeat="usuario in vm.usuarioList track by usuario.id">
                    <mdt-cell>{{usuario.nome}}</mdt-cell>
                    <mdt-cell>{{usuario.email}}</mdt-cell>
                    <mdt-cell>{{usuario.permissao}}</mdt-cell>
                    <mdt-cell html-content="true">
                        <div class="crop">
                            <md-button class="md-icon-button md-primary" aria-label="Editar"
                                       ng-click="vm.editar(usuario)">
                                <md-icon md-svg-icon="../images/icon/ic_mode_edit_black_18px.svg"></md-icon>
                            </md-button>
                        </div>
                    </mdt-cell>
                </mdt-row>

isaiastavares avatar Sep 09 '16 17:09 isaiastavares

@netanelwebzi did that solve your problem?

iamisti avatar Sep 12 '16 20:09 iamisti

@iamisti no, because I need a table with ajax, search, pagination and buttons to work. your example for ajax search support: http://codepen.io/iamisti/pen/RRrjLk

I need example of ajax search support with buttons on some column, when I try to make mdt-custom-cell with md-buttons its not working and not displaying the md-buttons.

Please try to give me example of working ajax search support with md-buttons in the table.

netanelwebzi avatar Sep 13 '16 10:09 netanelwebzi

I am having this issue. I receive an error in the JS console: https://docs.angularjs.org/error/ngTransclude/orphan?p0=%3Cbutton

Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found.

Is there a supported way to have the whole row be a clickable element(via data-ui-sref) which has the md-ink-ripple animation effects? Maybe this would avoid using the md-button

<mdt-table table-card="{title: 'Customer List'}" paginated-rows="{isEnabled: true, rowsPerPageValues: [5,10,20,50]}"
           mdt-row-paginator="paginatorCallback(page, pageSize)"
           mdt-row-paginator-error-message="Error happened during loading customers."
           mdt-trigger-request="getLoadResultsCallback(loadPageCallback)"
           mdt-row="{
            'table-row-id-key': 'id',
            'column-keys': [
                'id',
                'email',
                'date_created',
                'actions'
            ],
        }">
    <mdt-header-row>
        <mdt-column align-rule="left">ID</mdt-column>
        <mdt-column align-rule="right">Email</mdt-column>
        <mdt-column align-rule="right">Date Created</mdt-column>
        <mdt-column align-rule="right">Actions</mdt-column>
    </mdt-header-row>
    <mdt-custom-cell column-key="actions">
        <md-button class="md-primary md-raised">Edit</md-button>
    </mdt-custom-cell>
</mdt-table>

jdnwi avatar Sep 20 '16 14:09 jdnwi

There is not a proper way for using a md-button inside a mdt-custom-cell yet. But I found a workaround by using a custom directive.

// This directive creates a md-button with an md-icon inside.
.directive('mdtCustomCellButton', function () {
  return {
    template: '<md-button class="md-primary"><md-icon>edit</md-icon></md-button>',
  };
});

In your html you will use (replacing with your specific column-key):

<mdt-custom-cell column-key="<id>">
  <mdt-custom-cell-button></mdt-custom-cell-button>
</mdt-custom-cell>

mateosss avatar Sep 25 '16 02:09 mateosss

@netanelwebzi You can try to use md-button inside mdt-custom-cell with md-svg-icon

<mdt-custom-cell column-key="protein">
    <md-button class="md-icon-button launch">
        <md-icon md-svg-icon="launch"></md-icon> 
    </md-button>
</mdt-custom-cell>

just do not forget about $mdIconProvider

  app.config(function($mdIconProvider) {
      $mdIconProvider
        .defaultIconSet('assets/mdi/mdi.svg')
    });

see md icons docu

webcane avatar Sep 25 '16 08:09 webcane

Hello,

First of all, thank for this very useful project.

I have the same problem, I can't add any directive in <mdt-custom-cell> (Material directive or custom directive).

I fork your Codepen by adding <mdt-custom-cell> with inside a native button and Material button: the Material button generates this error.

I note it would be nice adding a Codepen with the option <mdt-custom-cell> in your demos.

laurentperroteau avatar Oct 19 '16 10:10 laurentperroteau

@laurentperroteau I'm not why this issue is happening, but here is a simple solution: http://codepen.io/iamisti/pen/PGxwAV

Basically wrapping the material button directive into your own directive.

wrapping the directive

.directive('mdtCustomCellButton', function () {
  return {
    template: '<md-button class="md-primary md-raised">Angular Material button</md-button>',
  };
});

and using it

<mdt-custom-cell column-key="iron">        
    <mdt-custom-cell-button ng-click="clientScope.hello()">Angular Material button</mdt-custom-cell-button>
    </mdt-custom-cell>
</mdt-header-row>

iamisti avatar Oct 19 '16 11:10 iamisti

Thanks, it works

laurentperroteau avatar Oct 19 '16 13:10 laurentperroteau

@iamisti is there a way to make the mdtCustomCellButton behave as per the row?

I'm trying to add buttons in a column and that button would enable/disable the row by posting a http request, then use css to disable the row. But i'm not able to pass anything to the button.

I was thinking of something along the lines of adding a toggleButton (like deleteSelectedRows) into the customCellButton directive, but i'm having issue accessing the ctrl inside the `link: function($scope, element, attrs, actrl) function.

any ideas?

cryptokoala4 avatar Oct 26 '16 05:10 cryptokoala4

@jackywhlee If you can help me and provide a codepen example, I can try to investigate what the issue is and hopefully fixing it too.

iamisti avatar Oct 27 '16 06:10 iamisti