Flex widget datagrid cannot select a row and sort after refresh the dataProvider

4280
2
Jump to solution
01-05-2015 08:39 PM
WuYang
by
New Contributor II

Hi everyone,

In my flex project, I have 2 widgets:

widget 1 -  user input searching criteria, and when click "Ok", close widget 1 and open widget 2. widget 2 - use the searching criteria from widget 1 and display the result in a datagrid (from database).

I have successfully passed the searching criteria from widget 1 to widget 2 and the datagrid can display data according to different searching criteria in widget 1. but the datagrid cannot select a row or sorting or scrolling.

In widget 2 init() function, I add this line:

ws.GetData(query);//query is from widget 1

In the function of getting data I use:

public function GetData(event:ResultEvent):void {

    datagrid.dataProvider = null;    

    ws.GetData(query); 

    datagrid.dataProvider = event.result;

}

The problem is:

If I add the line of   datagrid.dataProvider = null; The datagrid data will be refresh according to different searching criteria from widget 1, but the datagrid cannot be used properly (cannot select, sort, scroll).

If I remove the line of datagrid.dataProvider = null; the datagrid can be used properly. but the data in the datagrid will never be updated according to dfferent searching criteria. It means it always display the first time searching result.

How can make it work properly? Thanks in advance.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Wu Yang,

Your workflow seems a little strange... You say that you have:

ws.GetData(query);//query is from widget 1

in the init function of  widget 2

then:

In the function of getting data I use:

public function GetData(event:ResultEvent):void {

    datagrid.dataProvider = null;    

    ws.GetData(query); 

    datagrid.dataProvider = event.result;

}

So it looks like you are trying to get the data again in the ResultEvent?...

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Wu Yang,

Your workflow seems a little strange... You say that you have:

ws.GetData(query);//query is from widget 1

in the init function of  widget 2

then:

In the function of getting data I use:

public function GetData(event:ResultEvent):void {

    datagrid.dataProvider = null;    

    ws.GetData(query); 

    datagrid.dataProvider = event.result;

}

So it looks like you are trying to get the data again in the ResultEvent?...

0 Kudos
WuYang
by
New Contributor II

Hi Robert,

Yes there is something wrong with my code, I have managed to resolve it. Thanks a lot for the attention.

0 Kudos