ngReactGrid icon indicating copy to clipboard operation
ngReactGrid copied to clipboard

Highlight search terms in the cell.

Open ashishdamania opened this issue 10 years ago • 8 comments

It would be nice to highlight search field entry in the cells. I am currently using this filter to highlight terms in the Angular rendered Table:

<style>
      .ui-match { background: yellow; }
</style>
<script>
app.filter('highlight', function () {
  return function (text, search, caseSensitive) {
    if (search || angular.isNumber(search)) {
      text = text.toString();
      search = search.toString();
      if (caseSensitive) {
        return text.split(search).join('<span class="ui-match">' + search + '</span>');
      } else {
        return text.replace(new RegExp(search, 'gi'), '<span class="ui-match">$&</span>');
      }
    } else {
      return text;
    }
  };
});
</script>

I am not sure how can I render it using react.js. Thank you.

ashishdamania avatar Jun 09 '14 16:06 ashishdamania

@deepthoughts Interesting, this sounds like a good feature request. I'll see what I can do sometime this week to work on this. This would probably need to be implemented in the ngReactGridBodyRowCell component. The question then becomes, if it should support highlight on cells that define a render method, I'm inclined to say no, this would only work with cells that have a basic render.

josebalius avatar Jun 09 '14 18:06 josebalius

@josebalius Thanks for the reply. I guess it would be fine just to highlight "Regular/Basic render" cells. I need to look at React library in more details.

ashishdamania avatar Jun 09 '14 18:06 ashishdamania

@deepthoughts Yeah, the implementation for this would happen on this file: https://github.com/josebalius/ngReactGrid/blob/master/src/jsx/reactGrid.jsx#L295 at line 295. I just updated the README with how to build ngReactGrid, you can give it a try and see if maybe you can get the highlight feature to work.

josebalius avatar Jun 09 '14 18:06 josebalius

I guess it would also work in .jsx part of ngReactGrid.js file. I am relatively a newbie in Javascript overall so please bear with me. Thanks for all the help.

ashishdamania avatar Jun 09 '14 19:06 ashishdamania

Jose, any progress with this feature? I think that is a cool and helpful feature.

rhelenagh avatar Jul 02 '14 20:07 rhelenagh

@rhelenagh I have a proof of concept in the works, I'll try to publish it soon. Hopefully in version 0.7.0

Editable cells is in the works right now.

josebalius avatar Jul 02 '14 20:07 josebalius

Fantástico!

rhelenagh avatar Jul 02 '14 21:07 rhelenagh

This will be coming soon in react-grid: https://github.com/josebalius/react-grid

josebalius avatar Apr 22 '15 23:04 josebalius