Return a Cell Index based on criteria

Hi all,

Sorry - this is probably a very basic question, but something that is stumping me right now.

I have a RG of users, sorted, and I want to show text above the RG telling the Current User which number they are in the RG list.

I know it would be Cell Index, but I can’t think of how to extract the Cell Index for that particular user.

Am I embarrassing myself here? Is it completely simple?

Thanks

Andrew.

Hey there, im not sure if im understanding 100% your question.

So you want to show the cell index for only current user? Or all users can see the other users number?

Btw there’s an example how to show current cell index:

https://puu.sh/zAmvl/0c4bd1a6ea.png

Yes - I want to show it for just the Current User, but not in the Repeating Group… In a text above the repeating Group.

I have a leaderboard showing Rank # for each cell (e.g. Current Cell’s Index).

Above (and separate to) that RG, I want a text which says… Your Rank: #?. It is that ? which I am not sure how to achieve.

What criteria are you using to sort the users?

I am not aware of the ability to access the cell index of a repeating group from outside of the repeating group. The cell index is not part of the underlying data source that feeds the repeating group…it is more of a derived value, which Bubble doesn’t seem to expose. So I don’t think there is a way to have your text area at the top say “Repeating Group User’s List of User’s Cell index”.

However, this intrigued me so I found a work around for your case. First, you need to enable the “Expose the option to add an ID attribute to HTML elements” in the General settings tab of your app. In the text field that you are using to show the “Your rank is #” info, put a name in the ID attribute field. For demo purposes, I called it “currentUserRank”

Then add the “Components” plugin made by the folks at CoBubble https://bubble.io/plugin/components-1504367351709x922713012766769200
and then put a JavaScript element IN your repeating group and make it invisible on page load. Within the JavaScript element, put a condition that is “When current cell’s User is Current User” and change the HTML property to have this JavaScript

You will have to put all the JavaScript code in EXCEPT for the Current Cell’s index part and then add that in using the Bubble Insert Dynamic Data interface.

And there ya go. When the repeating group loads, the row that has the current user will fire off some JavaScript that sets the value of your text field.

Here is my demo of this (note in my demo I used an input to get the comparison value instead of Current User so that I could test it with different names)

and here is the editor so you can see what I did

Marc

2 Likes

Wow - Thanks @mguerrasio. HTML / Javascript is not something I am strong with (have only done some basic FB share buttons and PDF viewing boxes before), but this looks amazing. I will have a look later (am at work at the moment) and see if I can get my head around it.

If you’ve solved it - thanks very, very much.

Must admit - I assumed it was a simple thing I was missing - would have thought this would be a fairly common requirement.

This topic was automatically closed after 70 days. New replies are no longer allowed.