Is there a method to force scroll to bottom for a flex repeater on page load?
given view.root.flexRepeater as page layout?
Is there a method to force scroll to bottom for a flex repeater on page load?
given view.root.flexRepeater as page layout?
I have requested an onLoad event handler:
Causing a component to automatically scroll would likely require resorting to JavaScript injection, unless that, too, got implemented as a feature of Perspective. I'm pretty sure that doesn't exist. You might be able to hack it by way of calling .focus()
on an element at the bottom...
i got something that appears to work in initial testing.
on template for flex repeater
Create a params = Last
create a message handler on the bottom item or item you want to focus (must be a visible item)
type = focusField
script
if self.view.params.Last:
self.focus()
then on page with flex repeater create a custom property with expression binding to your repeater instances (or source for instances)
then transform script with - this will cause it to scroll down whenever the instances is updated
I think you could also put this within the transform script below this.
system.perspective.sendMessage( messageType="focusField", scope="page")
for your repeater instances for example I am doing an SQL query to get instance parameters
messageList = []
# Convert dataset to a list for index access
pyData = list(system.dataset.toPyDataSet(value))
lastIndex = len(pyData) - 1
for i, row in enumerate(pyData):
lastValue = True if i == lastIndex else False
messageDict = {
"MessageID": row["MessageID"],
"Last": lastValue
}
messageList.append(messageDict)
return messageList
If you want it to only run once on page load and not if instances change then maybe make custom parameter custom.runOnce initial value = True and add if statement to transform script and set to False within the if statement.
If you need to automatically scroll to the bottom on page load...
Then maybe your page is upside down and you should be displaying things in a different order ?
I'm not saying that's always the case, but it's something to consider. Simply reversing the order of your flex repeater might be just what you need.