mdDataTable icon indicating copy to clipboard operation
mdDataTable copied to clipboard

row click callback

Open IsNull opened this issue 7 years ago • 8 comments

I wonder if I missed it, but I can not see how to register a callback when the user clicks a row. It seems related to #166.

It would be nice if one could do something along:

<mdt-table mdt-row-click="myRowClickCallback(row)">
 ...
</mdt-table>

What is the current way of handling this use-case? (I'm using AJAX queries, so this limits my abilities to show custom cells as buttons)

Thanks for all your effort you put in this great library 👍

IsNull avatar Oct 19 '16 09:10 IsNull

@IsNull there is no callback feature like that. Not yet, but if you need it I can easily build that in. So you'd need all the data passed to the callback when you click a row, right?

iamisti avatar Oct 19 '16 12:10 iamisti

Thank you for the fast reaction.

Well I would just make a context reference "row" which references the clicked row object. So the developer can choose what property he wants to pass to the call back, eg:

  • The whole object mdt-row-click="myRowClickCallback(row)"
  • Only a property (field) of the row mdt-row-click="myRowClickCallback(row.name)"

What do you think, is this feasible?

IsNull avatar Oct 19 '16 12:10 IsNull

Thinking about it, there might be another approach:

Since the purpose is to give the user the ability to select one row by clicking on it, you could:

  • Support only one row can be selected (currently it is always multi-select) multi-selection="false"
  • Support to select the row by clicking it anywhere, not just the checkbox. select-on-rowclick="true"
<mdt-table 
             selectable-rows="true"
             multi-selection="false"
            select-on-rowclick="true">
 ...
</mdt-table>

multi-selection would need to be set to true by default to not break current code.

Maybe this is closer to your current API.

IsNull avatar Oct 19 '16 12:10 IsNull

Hello,

I have the same request:

<mdt-table
    mdt-row="{...}">

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

    ...

I need a click callback on row to change view.

I also specify I have buttons (with different click event) in some custom-cell (but it's maybe another problem).

Thanks

laurentperroteau avatar Nov 18 '16 08:11 laurentperroteau

Hello @iamisti , have you any idea how to simply (maybe temporarily) add this feature? Or this feature need big development? Thanks

laurentperroteau avatar Nov 23 '16 10:11 laurentperroteau

+1

rwe87 avatar Nov 24 '16 10:11 rwe87

+1

vibhanshuc avatar Dec 07 '16 12:12 vibhanshuc

You can use this : https://github.com/rvt/mdDataTable/commit/627bb8b5449cadb600836481fa7d2327060d8aac see clicked-row-callback

For Example:

clicked-row-callback="$ctrl.rowClicked(rowId)"

In code:

                    self.rowClicked = function (rowId) {
                      .....
                    };

rvt avatar Feb 16 '17 19:02 rvt