angular-ui/ui-grid

cellTemplate function with argument

Open

#5 828 ouverte le 22 nov. 2016

Voir sur GitHub
 (7 commentaires) (6 réactions) (0 assignés)JavaScript (2 496 forks)batch import
good first issue

Métriques du dépôt

Stars
 (5 395 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

  • You have searched the open issues to see if this bug has been filed before. We don't want duplicate issues.
  • You have reviewed the tutorials and documentation to ensure you are using the grid correctly. ui-grid.info
  • You are using the latest version of the grid. Older versions are not patched or supported.

It would be interesting to be able to define 'cellTemplate' with a function like the example below.

Example:

//The dataItem variable is the same thing as row.entity
cellTemplate: function(dataItem: {}) {
  return '<h1>{{dataItem | json}}</h1>';
}

I would like to have this feature, because I abstracted the usage of ui-grid in my own component and I want something more generic in case we want to replace ui-grid by another grid in the future. I don't want to use 'row.entity' (neither COL_FIELD or getCellValue...) because ag-grid or kendo or any other grid have different signatures, a function returning the dataItem Object is more reusable. If some day we decide to replace ui-grid by another one (could be ui-grid v4!), and if 'row.entity' was replaced by something else, then we will be screwed. With a function(datItem) in 'cellTemplate', we will have just one place where we will need to change that: in the generic component only...

Guide contributeur