PDA

View Full Version : [CLOSED] Column order on grid panel store reorder?



CanopiusApplications
Jun 30, 2015, 10:11 AM
Hi

I have a grid with

1. ColA
2. ColB

The user can then reorder these column to

1. ColB
2. ColA

This is great, I then use getRowsValues to pass the grid back to the server however the order of the column is ColA - ColB and not ColB - ColA.
Is there anyway to get getRowsValues to pass back in the new order?

Thanks,
Dan

Daniil
Jun 30, 2015, 3:06 PM
Hi @CanopiusApplications,

Yes, .getRowsValues() doesn't reflect the columns' order and there is no option in API to reflect it.

You can manually change the object returned by
.getRowsValues() call according to the columns order.

Though, I am not sure why you need that. Could you, please, clarify? Do you reflect the data on server by index? If so, I would recommend to reflect the data by a Column's DataIndex (i.e. ModelField's Name).

CanopiusApplications
Jun 30, 2015, 3:36 PM
Hi Daniil

Ok the situation is I have 2 grids which are dynamically generated so lets say
GridA - has columns 1 thru 10.
GridB - has columns A thru M

The user can then drag columns in either grid to change the column order. Once they are happy with the order they click a button which posts both grids back to the server where it generates a 3rd grid which amalgamates the columns (based on the new order) and adds calculates the difference so it might look something like

Parent Col1 - 2
- B
- Difference between the column values

Parent Col2 - 1
- A
- Difference between the column values

Basically just comparing 2 grids and amalgamating into a 3rd after they have dragged the various columns around into the order they want.

What I have done is posted but state and rowvalues back to the server and manipulated from there which works well enough.




<%--YOU COULD DO THIS IN A CALLBACK AND PLACE THE EXPAND ON SUCCESS -- WOULD PROBABLY BE BETTER--%>
<Click Handler="Ext.net.Mask.show({ msg: 'Building Comparison....' }); #{gpRMSDiff}.expand(); Daan.direct.ctlCatResults.CompareRMS(Ext.encode(#{ gpRMSPrevious}.getState().columns), Ext.encode(#{gpRMSCurrent}.getState().columns), Ext.encode(#{gpRMSPrevious}.getRowsValues({ selectedOnly: false })), Ext.encode(#{gpRMSCurrent}.getRowsValues({ selectedOnly: false })));"></Click>



The attached image explains it better.
24046

So unless you can see a simpler way of posting both the state and values back into a single object I will just go with this.

Ta,
D

Daniil
Jul 03, 2015, 9:16 AM
Yes, sending the columns order is a good solution and .getState().columns is also good for that.