Hi
I was looking for an solution.Any way to Changing the font colour of partial texts based on start and end index. And the sentence starting and ending index are obtained from collections( API response are stored in collections)
Example context : David visited the restaurant yesterday. David again visited today and hoped to visit again tomorrow
Collection:
Date Start End
2021/02/10 30 48
2021/02/11 61 65
2021/02/12 91 98
Expected Output: David visited the restaurant yesterday. David again visited today and hoped to visit again tomorrow
To change font colors (and other aspects) you need to utilize the HtmlText control.
So in your example (not sure how the logic relates to your collection data, but I'm sure you have that worked out) your htmltext would be:
"David visited the restaurant <font color='red'>yesterday</font>. David again visited <font color='red'>today</font> and hoped to visit again <font color='red'>tomorrow</font>"
I hope this is helpful for you.
Hy @RandyHayes
Actually API response i stored in collection will vary based on user filled out in textbox. and also i want to change the font color based on the index values
Let me put this simpler.
For example User enters context that contains yesterday,today,tomorrow like above mentioned example
so api response that im getting will be like
Date | Start index | End Index |
11-02-2020 | 61 | 65 |
12-02-2020 | 91 | 98 |
10-02-2020 | 30 | 48 |
im storing this api response to collection
so now what im looking for is to change the font color from the index 61 to 65 and 91 to 98 and 30 to 48 only
and my output will David visited the restaurant yesterday. David again visited today and hoped to visit again tomorrow
I am sorry, I am not understanding any connection of start and end index number and a date and users entering yesterday today and tomorrow to anything. There is no connection at all (in my interpretation of your message) to the sentence you are providing. What does 61 to 65 have to do with David visiting the restaurant yesterday, today or tomorrow or anything?
This is how UI looks like. When I click test button it trigger API which identifies date field with starting and ending position in the given context and api response (dates) stored in collection
now im looking for solution to highlight the dates in given context using start and end index from collection
I would suggest a Replace function then, but your index numbers do not correlate to the text.
Based on your image, 29 to 37 is "t yester" and 20 to 24 is "rest"
User | Count |
---|---|
259 | |
111 | |
97 | |
48 | |
41 |