You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@royale.apache.org by wkoch <wa...@boeing.com> on 2020/12/05 21:04:34 UTC

Sorting a Datagrid by Column

In flex the ability to sort (ascending or descending) the entire datagrid by
picking the column header.  I need this feature on my jewel datagrid but I'm
not sure how to get there.

I suspect I need to use the ButtonBar to fire a function that would sort the
data provider by column and refresh the grid?  using a collection sort?

In addition flex had simple icons to indicate what column things were sorted
on and the sort direction.  I guess I'm going to need some sort of icon in
the Button Bar?

Am I missing a bead or support class somewhere that would do this as opposed
to hand coding the whole thing?



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/

Re: Sorting a Datagrid by Column

Posted by Carlos Rovira <ca...@apache.org>.
Hi Warren,

that's right. You need to create an AL from your data and the use that AL
to feed the ALV that's the object needed to filter or order. In Flex it was
similar, we had ArrayCollection and ListCollectionView, and later was the
one providing filter and ordering capabilities



El lun, 7 dic 2020 a las 16:49, wkoch (<wa...@boeing.com>) escribió:

> I got sorting to work.  I had to "double" wrap it.
>
> Grid_dp = new ArrayListView(new ArrayList(jsonDataObject.PEF_LIST));
>
>
>
> --
> Sent from: http://apache-royale-users.20374.n8.nabble.com/
>


-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira

Re: Sorting a Datagrid by Column

Posted by wkoch <wa...@boeing.com>.
I got sorting to work.  I had to "double" wrap it.

Grid_dp = new ArrayListView(new ArrayList(jsonDataObject.PEF_LIST));



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/

Re: Sorting a Datagrid by Column

Posted by Carlos Rovira <ca...@apache.org>.
Hi,

You need to wrap the ArrayList in ArrayListView that takes the first as a
parameter. Take a look at TDJ and notice that is wrapping the original AL
in ALV

El dom, 6 dic 2020 a las 21:06, wkoch (<wa...@boeing.com>) escribió:

> No I'm using an array list populated from a complex object coming in from a
> JSON call.
>
> [Bindable] private var jsonDataObject:Object;
> [Bindable] private var Grid_dp:ArrayList =  new ArrayList();
>
> From the result handler:
> jsonDataObject = JSON.parse(Get_GridData.data);
> Grid_dp = new ArrayList(jsonDataObject.PEF_LIST);
>
> PEF_LIST is basically all the fields you see in the datagrid.
>
>
>
> --
> Sent from: http://apache-royale-users.20374.n8.nabble.com/
>


-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira

Re: Sorting a Datagrid by Column

Posted by wkoch <wa...@boeing.com>.
No I'm using an array list populated from a complex object coming in from a
JSON call.

[Bindable] private var jsonDataObject:Object;
[Bindable] private var Grid_dp:ArrayList =  new ArrayList();

From the result handler:
jsonDataObject = JSON.parse(Get_GridData.data);
Grid_dp = new ArrayList(jsonDataObject.PEF_LIST);

PEF_LIST is basically all the fields you see in the datagrid.  



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/

Re: Sorting a Datagrid by Column

Posted by Carlos Rovira <ca...@apache.org>.
Hi,

for beads, I tried to add the list of beads in each Royale doc page
reference. So new users coming can have a place where all beads that can
apply to a particular component are listed (special, common, optional,...).
But these pages are "hand made" and need huge effort and time to maintime,
but I think is worth it. Is not like ASDoc that is generated from code.

These is an example:
https://apache.github.io/royale-docs/component-sets/jewel/list#relvant-beads

About DataGridSort. Probably the problem is that ArrayList is not sortable.
Are you using ArrayListView?

El dom, 6 dic 2020 a las 18:04, wkoch (<wa...@boeing.com>) escribió:

> I added in the bead but it's still not sorting.  Did I do it wrong or need
> to
> import something?
>
>
> <j:DataGrid localId="dg6" y="250"  height="246" dataProvider="{Grid_dp}">
>  <j:beads>
>   <j:DataGridColumnLabelsChange/>
>   <j:DataGridSort/>
>   <j:DataGridPresentationModel rowHeight="25" variableRowHeight="false"/>
>  </j:beads>
>  <j:columns>
>   <j:DataGridColumn label="BEMS"  dataField="PEF_BEMSID" columnWidth="100"
> itemRenderer="renderers.MyDataGridColumnRendererCenter"/>
>   <j:DataGridColumn label="Name"  dataField="PEF_NAME"   columnWidth="300"
> itemRenderer="renderers.MyDataGridColumnRenderer"/>
>   <j:DataGridColumn label="Email" dataField="PEF_EMAIL"  columnWidth="300"
> itemRenderer="renderers.MyDataGridColumnRenderer"/>
>   <j:DataGridColumn label="SAME"  dataField="PEF_NAME"   columnWidth="300"
> itemRenderer="renderers.MyDataGridColumnRenderer"/>
>  </j:columns>
> </j:DataGrid>
>
>
>
>
> --
> Sent from: http://apache-royale-users.20374.n8.nabble.com/
>


-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira

Re: Sorting a Datagrid by Column

Posted by wkoch <wa...@boeing.com>.
I added in the bead but it's still not sorting.  Did I do it wrong or need to
import something?


<j:DataGrid localId="dg6" y="250"  height="246" dataProvider="{Grid_dp}">
 <j:beads>
  <j:DataGridColumnLabelsChange/>
  <j:DataGridSort/>
  <j:DataGridPresentationModel rowHeight="25" variableRowHeight="false"/>
 </j:beads>
 <j:columns>
  <j:DataGridColumn label="BEMS"  dataField="PEF_BEMSID" columnWidth="100" 
itemRenderer="renderers.MyDataGridColumnRendererCenter"/>
  <j:DataGridColumn label="Name"  dataField="PEF_NAME"   columnWidth="300" 
itemRenderer="renderers.MyDataGridColumnRenderer"/>
  <j:DataGridColumn label="Email" dataField="PEF_EMAIL"  columnWidth="300" 
itemRenderer="renderers.MyDataGridColumnRenderer"/>
  <j:DataGridColumn label="SAME"  dataField="PEF_NAME"   columnWidth="300" 
itemRenderer="renderers.MyDataGridColumnRenderer"/>
 </j:columns>
</j:DataGrid>




--
Sent from: http://apache-royale-users.20374.n8.nabble.com/

Re: Sorting a Datagrid by Column

Posted by wkoch <wa...@boeing.com>.
No I completely missed that in TDJ.  I saw it in the Royale API but it was
tied to MX controls so I assumed it wasn't available.  I look under
org.apache.royale in the API and never go into the other groups. There was
nothing in the API on the Jewel datagrid about it either.

I can live without the arrows.  I will give the bead a go.

FYI - I think that's been my biggest struggle so far -- the PAYG and finding
things.  Especially when they were baked into Flex.



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/

Re: Sorting a Datagrid by Column

Posted by Carlos Rovira <ca...@apache.org>.
Hi,

Did you know about DataGridSort bead? you can see an example in TDJ's
DataGridPlayGround. The second one on the page.
Unfortunately, we still don't have arrows showing direction. Going to see
if I can get some time to bring that

El sáb, 5 dic 2020 a las 22:04, wkoch (<wa...@boeing.com>) escribió:

> In flex the ability to sort (ascending or descending) the entire datagrid
> by
> picking the column header.  I need this feature on my jewel datagrid but
> I'm
> not sure how to get there.
>
> I suspect I need to use the ButtonBar to fire a function that would sort
> the
> data provider by column and refresh the grid?  using a collection sort?
>
> In addition flex had simple icons to indicate what column things were
> sorted
> on and the sort direction.  I guess I'm going to need some sort of icon in
> the Button Bar?
>
> Am I missing a bead or support class somewhere that would do this as
> opposed
> to hand coding the whole thing?
>
>
>
> --
> Sent from: http://apache-royale-users.20374.n8.nabble.com/
>


-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira