0

The smart-table documentation only details how to select a row of data, not an individual cell (the intersection of a row and a column).

I also found this conversation where the owner of the project states that selection by cell is not possible.

Is there any plugin or 3rd party solution that adds support to smart-table for selection by cell, or a simple way to do it manually?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Jacob Ritchie
  • 1,261
  • 11
  • 22
  • what are you trying to do? Can also use your own directives in table – charlietfl Sep 21 '15 at 20:30
  • I'm trying to use smart-table to represent a 2D grid, where each cell is selectable and has information associated with it, which is displayed when it is selected. I'm interested in the answer to the question in general, though. – Jacob Ritchie Sep 21 '15 at 20:33
  • since you control the ng-repeat and have access to each `row` it's not difficult to add a directive to do whatever you need. Look at *cell template* example in docs – charlietfl Sep 21 '15 at 20:44
  • If it's not too much trouble, do you think that you could elaborate? I am not very familiar with either angular or smart-table, and I can't figure out what to do based off of your comment and the example. – Jacob Ritchie Sep 21 '15 at 20:57

1 Answers1

1

You can actually select by cell, but it's not how you would normally use smart-table and it's better to just use a plain HTML5 table for the use case you've given here

What you can do is to use another ng-repeat for the columns of the rows and then access them using $parent.$index for the row and $index for the column (of course it's always better to access by the current iterated item rather then using indices when dealing with dynamic tables).

And then use your plain angular mouse event directives.

Here's a plunker

svarog
  • 9,477
  • 4
  • 61
  • 77