angularjs - How to get row index in angular ui-grid 3.0 -
i'm working angular ui-grid version 3.0 , can not find way index of row, add numeration column grid. me.
there isn't way index of row easily, depends you're trying do. expect numbering when sorts data - want numbers stay in original data, or want them change , align new sort order?
in faq http://ui-grid.info/docs/#/tutorial/499_faq find:
the question here you're trying achieve. want actual row index, or want display sequential id in rows?
if latter, can adding counter column data:
$scope.mydata.foreach( function( row, index){ row.sequence = index; });
if want show index of row within grid internals, depends on internal want. can index of row within grid.rows, show row stands in original rows list (not filtered nor sorted), or index of row within grid.rendercontainers.body.visiblerowcache (filtered , sorted), or render index of row within displayed rows (given virtualisation, particularly useless number).
if you're ok whenever sorts or filters numbers change, celltemplate, like:
celltemplate: '<div class="ui-grid-cell-contents">{{grid.rendercontainers.body.visiblerowcache.indexof(row)}}</div>'
Comments
Post a Comment