29 June 2009
Xcelsius: Default Selected Item From Dynamically Generated Labels
Consider this scenario. I have a Combo Box whose labels is a list of years retrieved by a web service. The range given for the Combo Box's labels is 6 cells and the option to ignore blank cells is checked so that if less than 6 years is returned by the web service, the Combo Box will not display the empty cells.
Here is what the model looks like so far. Notice the range for the Combo Box's labels on the left and on the right:
Now, let's assume that the web service will return an undetermined number of years every time it is queried. A simple example would be as time advances. This year, the web service will return 1 value, "2009". Next year, it will return two values, "2009" and "2010". And so on and so forth.
So for this year, the model will have 1 out of 6 cells occupied. The next year, it will have 2 out of the 6 cells occupied. The following figure is an example:
Let's say I want the default selected label to be the current year. Because as time advances, more years are returned, the current year in the list will always advance one cell down. This is shown in the figure. On the left the current year, "2009" is in the first cell. On the right, the new current year, "2010", is in the second cell. That means I can never specify a specific cell to be the default selected label.
So how to solve it? Fortuantley, Xcelsius is already intelligent enough to do this for me. I just have to trick it in doing it because it is not obvious on how do it.
1) Create a new cell in the model, with a value equal to the current year. Use Excel's functions to get the current year to maintain the dynamic nature of the dashboard.
2) Make sure to uncheck the option to ignore blank cells, and select the newly created cell as the default selected option.
3) Check back the option to ignore blank cells AFTER you select the cell for the default selected label.
Okay I am done! Now no matter how many rows are returned by the web service, the current year will always be the default selected one.
So how does it work? Xcelsius does not care if the cell selected for the default label is within the same range for the labels. All it cares about is that the value in the cell is equal to at least 1 value in the range for the labels.
As you can see in the pictures, the current year will always be within the range for the labels. So there you have it.
Thanks for reading.
Xcelsius: Default Selected Item From Dynamically Generated Labels
I think we all have experienced the joy of generating a list of labels dynamically for a selector component in Xcelsius. I think we also might have experienced the frustration of trying to define a specific value from that dynamic list to be the default selected one.
Consider this scenario. I have a Combo Box whose labels is a list of years retrieved by a web service. The range given for the Combo Box's labels is 6 cells and the option to ignore blank cells is checked so that if less than 6 years is returned by the web service, the Combo Box will not display the empty cells.
Here is what the model looks like so far. Notice the range for the Combo Box's labels on the left and on the right:
Now, let's assume that the web service will return an undetermined number of years every time it is queried. A simple example would be as time advances. This year, the web service will return 1 value, "2009". Next year, it will return two values, "2009" and "2010". And so on and so forth.
So for this year, the model will have 1 out of 6 cells occupied. The next year, it will have 2 out of the 6 cells occupied. The following figure is an example:
Let's say I want the default selected label to be the current year. Because as time advances, more years are returned, the current year in the list will always advance one cell down. This is shown in the figure. On the left the current year, "2009" is in the first cell. On the right, the new current year, "2010", is in the second cell. That means I can never specify a specific cell to be the default selected label.
So how to solve it? Fortuantley, Xcelsius is already intelligent enough to do this for me. I just have to trick it in doing it because it is not obvious on how do it.
1) Create a new cell in the model, with a value equal to the current year. Use Excel's functions to get the current year to maintain the dynamic nature of the dashboard.
2) Make sure to uncheck the option to ignore blank cells, and select the newly created cell as the default selected option.
3) Check back the option to ignore blank cells AFTER you select the cell for the default selected label.
Okay I am done! Now no matter how many rows are returned by the web service, the current year will always be the default selected one.
So how does it work? Xcelsius does not care if the cell selected for the default label is within the same range for the labels. All it cares about is that the value in the cell is equal to at least 1 value in the range for the labels.
As you can see in the pictures, the current year will always be within the range for the labels. So there you have it.
Thanks for reading.
No comments:
Post a Comment
Feel free to write any comments or ideas!