mdDataTable
mdDataTable copied to clipboard
row click callback
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 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?
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?
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.
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
Hello @iamisti , have you any idea how to simply (maybe temporarily) add this feature? Or this feature need big development? Thanks
+1
+1
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) {
.....
};