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

Suggestion: expose the "_rowByItem" method #155

Closed
highfield opened this issue Dec 1, 2015 · 3 comments
Closed

Suggestion: expose the "_rowByItem" method #155

highfield opened this issue Dec 1, 2015 · 3 comments

Comments

@highfield
Copy link

Hello and congrats for this little gem.
I'm creating a real-time web app which should update the cells upon a socket notification. Everything works fine, but I had to dig into your code to get around of a problem. Here is my code:

                    if (item) {
                        var row = $("#elem_").jsGrid("_rowByItem", item);
                        if (row.length) {
                            $("#elem_").jsGrid("updateItem", row, msg.body);
                        }
                    }

NOTE: "item" is the reference of the record involved.

The recordset counts 100 rows, but the grid pages at blocks of 15. Now, when a notification hits a rows which is off the current page (highly probable), I must know in advance whether to update the cell or not. If I don't do it, the grid throws an exception.
For this reason, I suggest to expose (I mean publicly document) the "_rowByItem" method, which helped me.

@tabalinas
Copy link
Owner

Thank you for the feedback. Not sure I got your scenario entirely, anyway publishing this method could be reasonable. Thank you for suggestion!

@highfield
Copy link
Author

The scenario is the following:

  • populate the grid with 100 records/rows, for instance;
  • configure the grid to paginate the set by a size of 10;

The grid shows the records and works as a charm.
Now suppose that some event/notification/whatever wants to update a field of a certain record. You'll face two cases:

  • you are lucky and the record belong the page you're watching at;
  • the record is cached, but not currently displayed because the pagination.

The first case works fine, but the second would throw an exception because the non existent row. The simplest yet obvious thing to do is querying the grid in order to check the existence of the row.
If there's another way to do that, I'll happy to learn!
Thanks again.

@tabalinas
Copy link
Owner

I see. Anyway, in the latest release the method is published.
Thank you!

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

2 participants