You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2016/03/15 17:45:38 UTC

ADG is reset on dataProvider refresh

I have to filter  a dataProvider of an ADG. As soon as I refresh() to see
changes DataGrid is reset. All columns have lost their custom layout.
What's the best way of handling that problem?

Here is my code:
override public function set dataProvider(value:Object):void
{
if (value)
{
addEventListener("AlarmManagementImagesLoaded", loadAlarmManagementImages);
ArrayCollection(value).filterFunction = watchListFilterHiddenAssets;
ArrayCollection(value).refresh();
super.dataProvider = value;
}
}

Thanks

Re: ADG is reset on dataProvider refresh

Posted by Alex Harui <ah...@adobe.com>.
What is dataProvider.length after refresh()?

You still seem to be trying to filter at the same time you are setting the
data provider.  Without understanding your actual scenario it isn't clear
what to recommend.  If you have a small test case, create a JIRA issue for
it.

-Alex

On 3/15/16, 11:39 AM, "mark goldin" <ma...@gmail.com> wrote:

>Seems like I am filtering dataProvider correctly.
>Here is my latest code:
>set dataProvider:
>super.dataProvider = value;
>summaryLoaded();
>
>private function summaryLoaded():void
>{
>      ArrayCollection(dataProvider).filterFunction =
>watchListFilterHiddenAssets;
>      ArrayCollection(dataProvider).refresh();
>      validateNow();
>}
>
>For testing watchListFilterHiddenAssets returns false for every item.
>Still
>Grid shows all the data.
>
>On Tue, Mar 15, 2016 at 12:26 PM Alex Harui <ah...@adobe.com> wrote:
>
>>
>>
>> On 3/15/16, 10:20 AM, "mark goldin" <ma...@gmail.com> wrote:
>>
>> >Did you mean like this?
>> >super.dataProvider = value;
>> >ArrayCollection(dataProvider).filterFunction =
>> >watchListFilterHiddenAssets;
>> >ArrayCollection(dataProvider).refresh();
>> >
>> >That did not change anything.
>>
>> Well, if you want to filter immediately after setting, you may need a
>> validateNow() call.
>>
>> But it sounds to me like you are setting the dataProvider more than
>>once.
>> Usually when folks change the filters, they do not set the dataProvider
>> again.
>>
>> HTH,
>> -Alex
>>
>>


Re: ADG is reset on dataProvider refresh

Posted by OK <OK...@edscha.com>.
Perhaps as Alex said if there's no need in your scenario to overwrite the
dataProvider setter it may be better to decouple the filtering from the
datagrid:

// Apply filter
myAC.filterFunction = watchListFilterHiddenAssets;

 
<s:Datagrid dataprovider={myAC} />

HTH,
Olaf



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/ADG-is-reset-on-dataProvider-refresh-tp12246p12258.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: ADG is reset on dataProvider refresh

Posted by mark goldin <ma...@gmail.com>.
Seems like I am filtering dataProvider correctly.
Here is my latest code:
set dataProvider:
super.dataProvider = value;
summaryLoaded();

private function summaryLoaded():void
{
      ArrayCollection(dataProvider).filterFunction =
watchListFilterHiddenAssets;
      ArrayCollection(dataProvider).refresh();
      validateNow();
}

For testing watchListFilterHiddenAssets returns false for every item. Still
Grid shows all the data.

On Tue, Mar 15, 2016 at 12:26 PM Alex Harui <ah...@adobe.com> wrote:

>
>
> On 3/15/16, 10:20 AM, "mark goldin" <ma...@gmail.com> wrote:
>
> >Did you mean like this?
> >super.dataProvider = value;
> >ArrayCollection(dataProvider).filterFunction =
> >watchListFilterHiddenAssets;
> >ArrayCollection(dataProvider).refresh();
> >
> >That did not change anything.
>
> Well, if you want to filter immediately after setting, you may need a
> validateNow() call.
>
> But it sounds to me like you are setting the dataProvider more than once.
> Usually when folks change the filters, they do not set the dataProvider
> again.
>
> HTH,
> -Alex
>
>

Re: ADG is reset on dataProvider refresh

Posted by Alex Harui <ah...@adobe.com>.

On 3/15/16, 10:20 AM, "mark goldin" <ma...@gmail.com> wrote:

>Did you mean like this?
>super.dataProvider = value;
>ArrayCollection(dataProvider).filterFunction =
>watchListFilterHiddenAssets;
>ArrayCollection(dataProvider).refresh();
>
>That did not change anything.

Well, if you want to filter immediately after setting, you may need a
validateNow() call.

But it sounds to me like you are setting the dataProvider more than once.
Usually when folks change the filters, they do not set the dataProvider
again.

HTH,
-Alex


Re: ADG is reset on dataProvider refresh

Posted by mark goldin <ma...@gmail.com>.
Did you mean like this?
super.dataProvider = value;
ArrayCollection(dataProvider).filterFunction = watchListFilterHiddenAssets;
ArrayCollection(dataProvider).refresh();

That did not change anything.

On Tue, Mar 15, 2016 at 12:07 PM Alex Harui <ah...@adobe.com> wrote:

> Calling super.dataProvider will probably reset the DG.  I think most folks
> assign dataProvider and then filter later.
>
> -Alex
>
> On 3/15/16, 9:45 AM, "mark goldin" <ma...@gmail.com> wrote:
>
> >I have to filter  a dataProvider of an ADG. As soon as I refresh() to see
> >changes DataGrid is reset. All columns have lost their custom layout.
> >What's the best way of handling that problem?
> >
> >Here is my code:
> >override public function set dataProvider(value:Object):void
> >{
> >if (value)
> >{
> >addEventListener("AlarmManagementImagesLoaded",
> >loadAlarmManagementImages);
> >ArrayCollection(value).filterFunction = watchListFilterHiddenAssets;
> >ArrayCollection(value).refresh();
> >super.dataProvider = value;
> >}
> >}
> >
> >Thanks
>
>

Re: ADG is reset on dataProvider refresh

Posted by Alex Harui <ah...@adobe.com>.
Calling super.dataProvider will probably reset the DG.  I think most folks
assign dataProvider and then filter later.

-Alex

On 3/15/16, 9:45 AM, "mark goldin" <ma...@gmail.com> wrote:

>I have to filter  a dataProvider of an ADG. As soon as I refresh() to see
>changes DataGrid is reset. All columns have lost their custom layout.
>What's the best way of handling that problem?
>
>Here is my code:
>override public function set dataProvider(value:Object):void
>{
>if (value)
>{
>addEventListener("AlarmManagementImagesLoaded",
>loadAlarmManagementImages);
>ArrayCollection(value).filterFunction = watchListFilterHiddenAssets;
>ArrayCollection(value).refresh();
>super.dataProvider = value;
>}
>}
>
>Thanks