You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Kyle McKnight <ka...@gmail.com> on 2016/10/24 18:53:00 UTC

Updating data for List refreshes entire List and scrolls to the top

Hey everyone!

I have a List that has enough items that one must scroll down to see them
all.

When clicking an item, it updates the data for that ItemRenderer with a
quantity value.

When this happens, I'm calling refresh() on the data provider for the List
but this refreshes then entire List and causes it to scroll back up to the
top. Is there a way to only update the single ItemRenderer whose data
changed? Or is there some other way around this?

Thanks!

Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

Re: Updating data for List refreshes entire List and scrolls to the top

Posted by Alex Harui <ah...@adobe.com>.
On 10/25/16, 7:39 AM, "kamcknig" <ka...@gmail.com> wrote:

>Your solution works though it feels a bit hacky. I also get a flicker
>when I
>do it. So a lot of the items will blink out and back in for a split
>second.

refresh() does a full refresh.  itemUpdated and other methods will only
update an item, but might be more work to implement.

-Alex


Re: Updating data for List refreshes entire List and scrolls to the top

Posted by kamcknig <ka...@gmail.com>.
Your solution works though it feels a bit hacky. I also get a flicker when I
do it. So a lot of the items will blink out and back in for a split second.



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Updating-data-for-List-refreshes-entire-List-and-scrolls-to-the-top-tp13907p13922.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Updating data for List refreshes entire List and scrolls to the top

Posted by Vincent <vi...@after24.net>.
Hello Kyle,

If you want to use the refresh() method, a solution would be to :

1 - Store the verticalScrollPosition value of the scroller of the list 
(verticalScrollPosition is a property you can access via the viewport 
property of the scroller)
2 - Invoke the refresh method of the data provider
3 - Wait for the updateComplete event of the list
4 - Restore the verticalScrollPosition value to the stored one

Cheers.


Le 24/10/2016 � 23:00, Kyle McKnight a �crit :
> How am I doing that?
> The underlying data within an ArrayList gets updated. The ArrayList is the
> data provider to the List.
>
> Ya don't do that.
> OK :-D
>
> The suggestion given I believe would rely on binding which I'm trying to
> avoid. I hate littering my code with bindings and am only using Flex
> because I am required to for who I'm writing it for :) So I need a way to
> tell the item renderer that it needs to update and the only way I
> originally knew how was to refresh the entire list rather than just the
> one.
>
>
> Kyle McKnight
> Senior UI Engineer - Accesso
> 602.515.1444 (M)
>
> On Mon, Oct 24, 2016 at 4:13 PM, Clint M <cm...@gmail.com> wrote:
>
>> Inline below
>>
>> On Mon, Oct 24, 2016 at 11:53 AM, Kyle McKnight <ka...@gmail.com>
>> wrote:
>>
>>> Hey everyone!
>>>
>>> I have a List that has enough items that one must scroll down to see them
>>> all.
>>>
>>> When clicking an item, it updates the data for that ItemRenderer with a
>>> quantity value.
>>>
>> How are you doing that.
>>
>>
>>> When this happens, I'm calling refresh() on the data provider for the
>> List
>>> but this refreshes then entire List and causes it to scroll back up to
>> the
>>> top.
>>
>> Ya don't do that.
>>
>>
>>> Is there a way to only update the single ItemRenderer whose data
>>> changed? Or is there some other way around this?
>>>
>> It depends on how you're doing it in my first question but generally
>> something like that would just be handled in the itemRenderer like:
>>
>> data.quantity = newVal; <-- this will also trigger a collectionChange event
>> on the lists dataProvider that you could handle
>>
>> If you're bubbling a click event up and trying to handle it in a controller
>> then you could do something like:
>>
>> list.dataProvider[itemRenderer.itemIndex].quantity = newValue;
>>
>>
>>> Thanks!
>>>
>>> Kyle McKnight
>>> Senior UI Engineer - Accesso
>>> 602.515.1444 (M)
>>>


Re: Updating data for List refreshes entire List and scrolls to the top

Posted by Kyle McKnight <ka...@gmail.com>.
How am I doing that?
The underlying data within an ArrayList gets updated. The ArrayList is the
data provider to the List.

Ya don't do that.
OK :-D

The suggestion given I believe would rely on binding which I'm trying to
avoid. I hate littering my code with bindings and am only using Flex
because I am required to for who I'm writing it for :) So I need a way to
tell the item renderer that it needs to update and the only way I
originally knew how was to refresh the entire list rather than just the
one.


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Mon, Oct 24, 2016 at 4:13 PM, Clint M <cm...@gmail.com> wrote:

> Inline below
>
> On Mon, Oct 24, 2016 at 11:53 AM, Kyle McKnight <ka...@gmail.com>
> wrote:
>
> > Hey everyone!
> >
> > I have a List that has enough items that one must scroll down to see them
> > all.
> >
> > When clicking an item, it updates the data for that ItemRenderer with a
> > quantity value.
> >
>
> How are you doing that.
>
>
> >
> > When this happens, I'm calling refresh() on the data provider for the
> List
> > but this refreshes then entire List and causes it to scroll back up to
> the
> > top.
>
>
> Ya don't do that.
>
>
> > Is there a way to only update the single ItemRenderer whose data
> > changed? Or is there some other way around this?
> >
>
> It depends on how you're doing it in my first question but generally
> something like that would just be handled in the itemRenderer like:
>
> data.quantity = newVal; <-- this will also trigger a collectionChange event
> on the lists dataProvider that you could handle
>
> If you're bubbling a click event up and trying to handle it in a controller
> then you could do something like:
>
> list.dataProvider[itemRenderer.itemIndex].quantity = newValue;
>
>
> >
> > Thanks!
> >
> > Kyle McKnight
> > Senior UI Engineer - Accesso
> > 602.515.1444 (M)
> >
>

Re: Updating data for List refreshes entire List and scrolls to the top

Posted by Clint M <cm...@gmail.com>.
Inline below

On Mon, Oct 24, 2016 at 11:53 AM, Kyle McKnight <ka...@gmail.com> wrote:

> Hey everyone!
>
> I have a List that has enough items that one must scroll down to see them
> all.
>
> When clicking an item, it updates the data for that ItemRenderer with a
> quantity value.
>

How are you doing that.


>
> When this happens, I'm calling refresh() on the data provider for the List
> but this refreshes then entire List and causes it to scroll back up to the
> top.


Ya don't do that.


> Is there a way to only update the single ItemRenderer whose data
> changed? Or is there some other way around this?
>

It depends on how you're doing it in my first question but generally
something like that would just be handled in the itemRenderer like:

data.quantity = newVal; <-- this will also trigger a collectionChange event
on the lists dataProvider that you could handle

If you're bubbling a click event up and trying to handle it in a controller
then you could do something like:

list.dataProvider[itemRenderer.itemIndex].quantity = newValue;


>
> Thanks!
>
> Kyle McKnight
> Senior UI Engineer - Accesso
> 602.515.1444 (M)
>

Re: Updating data for List refreshes entire List and scrolls to the top

Posted by Kyle McKnight <ka...@gmail.com>.
I get the following error. Looks like at some sort of internal update. I've
made sure any index I'm passing in is > -1. And in the case I'm testing
it's 0. So internally it's getting a -1 somewhere and I'm not sure.

I'm now using listProvider.itemUpdated(listProvider.getItemAt(index)) where
index is > -1

mx.collections::ListCollectionView/getItemAt at
D:\development\accesso\flex_sdks\apache_flex_4.15.0_air_20\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:525
spark.components::DataGroup/finishVirtualLayout at
/Users/justinmclean/Documents/ApacheFlex4.15/frameworks/projects/spark/src/spark/components/DataGroup.as:1403
spark.components::DataGroup/updateDisplayList at
/Users/justinmclean/Documents/ApacheFlex4.15/frameworks/projects/spark/src/spark/components/DataGroup.as:1495
mx.core::UIComponent/validateDisplayList at
D:\development\accesso\flex_sdks\apache_flex_4.15.0_air_20\frameworks\projects\framework\src\mx\core\UIComponent.as:9531
mx.managers::LayoutManager/validateDisplayList at
D:\development\accesso\flex_sdks\apache_flex_4.15.0_air_20\frameworks\projects\framework\src\mx\managers\LayoutManager.as:744
mx.managers::LayoutManager/doPhasedInstantiation at
D:\development\accesso\flex_sdks\apache_flex_4.15.0_air_20\frameworks\projects\framework\src\mx\managers\LayoutManager.as:827
mx.managers::LayoutManager/doPhasedInstantiationCallback at
D:\development\accesso\flex_sdks\apache_flex_4.15.0_air_20\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1188



Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Mon, Oct 24, 2016 at 3:58 PM, OmPrakash Muppirala <bi...@gmail.com>
wrote:

> Calling refresh on the dataprovider is probably what is causing this.
>
> Have you tried using the itemUpdated() function on the dataprovider
> instead?
>
> Here is some info on that:
> http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0b
> f668d2-7fe7.html#WS2db454920e96a9e51e63e3d11c0bf69084-7b64
>
> On Mon, Oct 24, 2016 at 11:53 AM, Kyle McKnight <ka...@gmail.com>
> wrote:
>
> > Hey everyone!
> >
> > I have a List that has enough items that one must scroll down to see them
> > all.
> >
> > When clicking an item, it updates the data for that ItemRenderer with a
> > quantity value.
> >
> > When this happens, I'm calling refresh() on the data provider for the
> List
> > but this refreshes then entire List and causes it to scroll back up to
> the
> > top. Is there a way to only update the single ItemRenderer whose data
> > changed? Or is there some other way around this?
> >
> > Thanks!
> >
> > Kyle McKnight
> > Senior UI Engineer - Accesso
> > 602.515.1444 (M)
> >
>

Re: Updating data for List refreshes entire List and scrolls to the top

Posted by Kyle McKnight <ka...@gmail.com>.
I was looking for something like that. Will get back to you tomorrow with
whether it works for me or not!

Thanks!


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Mon, Oct 24, 2016 at 3:58 PM, OmPrakash Muppirala <bi...@gmail.com>
wrote:

> Calling refresh on the dataprovider is probably what is causing this.
>
> Have you tried using the itemUpdated() function on the dataprovider
> instead?
>
> Here is some info on that:
> http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0b
> f668d2-7fe7.html#WS2db454920e96a9e51e63e3d11c0bf69084-7b64
>
> On Mon, Oct 24, 2016 at 11:53 AM, Kyle McKnight <ka...@gmail.com>
> wrote:
>
> > Hey everyone!
> >
> > I have a List that has enough items that one must scroll down to see them
> > all.
> >
> > When clicking an item, it updates the data for that ItemRenderer with a
> > quantity value.
> >
> > When this happens, I'm calling refresh() on the data provider for the
> List
> > but this refreshes then entire List and causes it to scroll back up to
> the
> > top. Is there a way to only update the single ItemRenderer whose data
> > changed? Or is there some other way around this?
> >
> > Thanks!
> >
> > Kyle McKnight
> > Senior UI Engineer - Accesso
> > 602.515.1444 (M)
> >
>

Re: Updating data for List refreshes entire List and scrolls to the top

Posted by kamcknig <ka...@gmail.com>.
OK it appears that I got that error becuse I was passing the index of the
item in the "source" array. But on my data provider I had a filter on the
array so not all items were there. I have now instead dispatched the change
with the Object that was changed (FYI, I'm using Signals, not that it
matters). This fixes the issue with the index out of bounds error. But now
when the list updates, the item renderer in question seems to just
completely shrink and the content of it seems to be all messed up.



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Updating-data-for-List-refreshes-entire-List-and-scrolls-to-the-top-tp13907p13921.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Updating data for List refreshes entire List and scrolls to the top

Posted by OmPrakash Muppirala <bi...@gmail.com>.
Calling refresh on the dataprovider is probably what is causing this.

Have you tried using the itemUpdated() function on the dataprovider
instead?

Here is some info on that:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf668d2-7fe7.html#WS2db454920e96a9e51e63e3d11c0bf69084-7b64

On Mon, Oct 24, 2016 at 11:53 AM, Kyle McKnight <ka...@gmail.com> wrote:

> Hey everyone!
>
> I have a List that has enough items that one must scroll down to see them
> all.
>
> When clicking an item, it updates the data for that ItemRenderer with a
> quantity value.
>
> When this happens, I'm calling refresh() on the data provider for the List
> but this refreshes then entire List and causes it to scroll back up to the
> top. Is there a way to only update the single ItemRenderer whose data
> changed? Or is there some other way around this?
>
> Thanks!
>
> Kyle McKnight
> Senior UI Engineer - Accesso
> 602.515.1444 (M)
>