Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight search terms in the cell. #5

Open
ashishdamania opened this issue Jun 9, 2014 · 8 comments
Open

Highlight search terms in the cell. #5

ashishdamania opened this issue Jun 9, 2014 · 8 comments

Comments

@ashishdamania
Copy link

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.

@josebalius
Copy link
Owner

@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.

@ashishdamania
Copy link
Author

@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.

@josebalius
Copy link
Owner

@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.

@ashishdamania
Copy link
Author

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.

@rhelenagh
Copy link

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

@josebalius
Copy link
Owner

@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.

@rhelenagh
Copy link

Fantástico!

@josebalius
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants