1

Is it possible to obtain the column key inside a cell renderer?

For example in the `CustomRenderComponent Demo the value of the cell and the row data is injected like this:

@Input() value: string | number;
@Input() rowData: any;

is there a way to get the current column key? Something like:

@input column: string;

or get a Cell instance?

The Cell class has method like this:

getColumn(): Column {
  return this.column;
}

Smart Table Issue

https://github.com/akveo/ng2-smart-table/issues/518

Ole
  • 41,793
  • 59
  • 191
  • 359
  • Basically what you want ? Do you want to access row or column data ? – Sachin Shah Nov 18 '18 at 17:47
  • Yes - In the repository example the renderer only receives the cell `value` and `rowData`. I'm also wondering what column the cell is in? – Ole Nov 18 '18 at 19:08

1 Answers1

1

Look at custom-view.component.ts. It has a method getPatch() that returns a ViewCell. Change this method to return a Cell.

Now the custom renderer implementation will be patched with the entire Cell instance, rather than a few of the components belonging to it.

Create a new interface that this type of renderer should implement, rather than just having it implement the ViewCell interface.

Ole
  • 41,793
  • 59
  • 191
  • 359
Sachin Shah
  • 4,503
  • 3
  • 23
  • 50
  • IIUC the `row.data` is the same thing as the `rowData` that the custom render component inherits from the `ViewCell` interface? – Ole Nov 19 '18 at 05:02
  • @Ole that you have to check in your case. When I console.log(row). I got the data in `row.data`. – Sachin Shah Nov 19 '18 at 05:29
  • Yes that's what I get too. Looks like the custom cell renderer has to be redesigned in order to pass the column value to the component. I'm working on it now. I'll post an update as soon as the prototype is ready. – Ole Nov 19 '18 at 08:07
  • @Ole ok anything else for me ? – Sachin Shah Nov 19 '18 at 08:33
  • I changed your answer with the implementation approach I'm going to use. – Ole Nov 20 '18 at 02:58
  • NP - Also added a link I found to my question for an issue that's been open for a while that asks for this to be implemented. – Ole Nov 20 '18 at 04:34