[ 
https://issues.apache.org/jira/browse/FLEX-35224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15783043#comment-15783043
 ] 

Pan Li edited comment on FLEX-35224 at 12/28/16 3:07 PM:
---------------------------------------------------------

The three components I was trying to create for paging:
1 The model with page is very straight forward.
2 To filter the records in "current page", it looks like the only layer between 
actual data provider to UI controls is in DataItemRendererFactoryForArrayList:
{code}
protected function dataProviderChangeHandler(event:Event):void
                {
                        var dp:IArrayList = dataProviderModel.dataProvider as 
IArrayList;
                        if (!dp)
                                return;
                        
                        dataGroup.removeAllElements();
                        
                        var listView:IListView = 
_strand.getBeadByType(IListView) as IListView;
                        var presentationModel:IListPresentationModel = 
_strand.getBeadByType(IListPresentationModel) as IListPresentationModel;
                        
                        var n:int = dp.length; 
                        for (var i:int = 0; i < n; i++)
                        {                               
                                var ir:ISelectableItemRenderer = 
itemRendererFactory.createItemRenderer(dataGroup) as ISelectableItemRenderer;
                                dataGroup.addElement(ir);
                                if (presentationModel) {
                                        UIBase(ir).height = 
presentationModel.rowHeight;
                                        
                                        // ensure that the IR spans the width 
of its column
                                        var style:SimpleCSSStyles = new 
SimpleCSSStyles();
                                        style.right = 0;
                                        style.left = 0;
                                        UIBase(ir).style = style;
                                }
                                setData(ir, dp.getItemAt(i), i);
                                
                                var newEvent:ItemRendererEvent = new 
ItemRendererEvent(ItemRendererEvent.CREATED);
                                newEvent.itemRenderer = ir;
                                dispatchEvent(newEvent);
                        }
                        
                        IEventDispatcher(_strand).dispatchEvent(new 
Event("itemsCreated"));
                }
{code}

I can get it work for my purpose to create a new 
DataItemRendererFactoryForArrayList
but one problem: the rendererfactory is a relative complex class, and it uses 
lots of implementation details of default DataGrid

3 the buttons to switch pages
I didn't find a good place to create the extra buttons for the UI, if I create 
a new "bead" and let it to add buttons for "strand", then I can't ensure that 
the code of buttons is added after all datagrid UI is created. Should I just 
create another DataView? It surely works but is there easy solution?


in summary I could have finish it following your suggestion, but my problems 
are 
1 it looks like there is no obvious "bead" to filter data list, the 
rendererfactory calls the raw data directly
2 there is no obvious place to create extra UI components for the control
it make the code more complex and easy to be break if DataGrid's code is 
updated.
If there were "datafilteringbead" (called in rendererfactory) and 
"extracontrolsbead" (called in DataGridView), then it could be easier


we had requested other features on filtering data grid data:
sorting on fields
https://issues.apache.org/jira/browse/FLEX-35222
and filtering on fields (not in jira now),
the both have very similar issues when implemented as FlexJS SDK extensions. 
Was I doing it wrong way? do you have more suggestion?



What if I implement these features by a custom FlexJS control which composite 
several existing controls like someone would do in other frameworks, for 
example a paging datagrid only needs a DataGrid and 4 buttons. I spend 2-3 
hours to create a working stub, it is pure FlexJS code (instead of FlexJS SDK 
code). Is it not encouraged to composite controls to implement extensions?




was (Author: [email protected]):
The three components I was trying to create for paging:
1 The model with page is very straight forward.
2 To filter the records in "current page", it looks like the only layer between 
actual data provider to UI controls is in DataItemRendererFactoryForArrayList:
{code}
protected function dataProviderChangeHandler(event:Event):void
                {
                        var dp:IArrayList = dataProviderModel.dataProvider as 
IArrayList;
                        if (!dp)
                                return;
                        
                        dataGroup.removeAllElements();
                        
                        var listView:IListView = 
_strand.getBeadByType(IListView) as IListView;
                        var presentationModel:IListPresentationModel = 
_strand.getBeadByType(IListPresentationModel) as IListPresentationModel;
                        
                        var n:int = dp.length; 
                        for (var i:int = 0; i < n; i++)
                        {                               
                                var ir:ISelectableItemRenderer = 
itemRendererFactory.createItemRenderer(dataGroup) as ISelectableItemRenderer;
                                dataGroup.addElement(ir);
                                if (presentationModel) {
                                        UIBase(ir).height = 
presentationModel.rowHeight;
                                        
                                        // ensure that the IR spans the width 
of its column
                                        var style:SimpleCSSStyles = new 
SimpleCSSStyles();
                                        style.right = 0;
                                        style.left = 0;
                                        UIBase(ir).style = style;
                                }
                                setData(ir, dp.getItemAt(i), i);
                                
                                var newEvent:ItemRendererEvent = new 
ItemRendererEvent(ItemRendererEvent.CREATED);
                                newEvent.itemRenderer = ir;
                                dispatchEvent(newEvent);
                        }
                        
                        IEventDispatcher(_strand).dispatchEvent(new 
Event("itemsCreated"));
                }
{code}

I can get it work for my purpose to create a new 
DataItemRendererFactoryForArrayList
but one problem: the rendererfactory is a relative complex class, and it uses 
lots of implementation details of default DataGrid

3 the buttons to switch pages
I didn't find a good place to create the extra buttons for the UI, if I create 
a new "bead" and let it to add buttons for "strand", then I can't ensure that 
the code of buttons is added after all datagrid UI is created. Should I just 
create another DataView? It surely works but is there easy solution?


in summary I could have finish it following your suggestion, but my problems 
are 
1 it looks like there is no obvious "bead" to filter data list, the 
rendererfactory calls the raw data directly
2 there is no obvious place to create extra UI components for the control
it make the code more complex and easy to be break if DataGrid's code is 
updated.

we had requested other features on filtering data grid data:
sorting on fields
https://issues.apache.org/jira/browse/FLEX-35222
and filtering on fields (not in jira now),
the both have very similar issues when implemented as FlexJS SDK extensions. 
Was I doing it wrong way? do you have more suggestion?



What if I implement these features by a custom FlexJS control which composite 
several existing controls like someone would do in other frameworks, for 
example a paging datagrid only needs a DataGrid and 4 buttons. I spend 2-3 
hours to create a working stub, it is pure FlexJS code (instead of FlexJS SDK 
code). Is it not encouraged to composite controls to implement extensions?



> DataGrid doesn't support paging on large data set
> -------------------------------------------------
>
>                 Key: FLEX-35224
>                 URL: https://issues.apache.org/jira/browse/FLEX-35224
>             Project: Apache Flex
>          Issue Type: Improvement
>            Reporter: Pan Li
>            Priority: Minor
>         Attachments: screenshot-1.png
>
>
> expected:
> Gird should support paging if data collection is large
> !screenshot-1.png!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to