Wednesday, August 29, 2012

Rearranging the column of af table in oracle adf

Hi  All,

Rearranging the column of  af table in oracle adf :

Use Case:
In one of my project we have to implemented the customization feature of the adf which we also known as MDS. Where  logged in user has option to rearrange the column's  of the af table .And if user logged out and logged -in again then he/she can see the old order of columns of the table.(it will persist column order)

But our business user also want reorder the column  of the table with it's initial order.Hence we need to implement somethings which will solved their purpose .

Implementation :
Since <af:column > has attribute called  DisplayIndex which contains index value of the column which is showing in the UI .By default value is -1  it  means there is no reorder of column at client side.

If you changed the order of the column the all the columns DisplayIndex will changed with the index and index will start 0.

Again making column into initial order we need to change the value of DisplayIndex with -1.After making this it will automatically display af table with it initial af:table order .

 I have created a command button and created action listener  method and added following code

    private RichTable richTableBinding;

    public void setRichTableBinding(RichTable richTableBinding) {
        this.richTableBinding = richTableBinding;
    }

    public RichTable getRichTableBinding() {
        return richTableBinding;
    }

       public void columnActionListener(ActionEvent actionEvent) {
        List<UIComponent> uiComponentList = richTableBinding.getChildren();
        for (UIComponent uiComponent : uiComponentList) {
            if (uiComponent instanceof RichColumn &&
                uiComponent.isRendered()) {
                ((RichColumn)uiComponent).setDisplayIndex(-1);
            }
            AdfFacesContext.getCurrentInstance().addPartialTarget(richTableBinding);
        }
    }

One more things i would like to add here that is in my last post i have created declarative component which will generate the report into different type of format .

But that  declarative component has  following limitation.

As a end user if i have changed the order of the columns of the table in UI side and after that  if  i generate the report they the order of report table will same as UI .But it is not happening with current scenario .But if i implement the same post scenario in my declarative component then it  would be achievable.

 I will try to add the same in declarative component .And will post later .


Coding is present  at following link

https://docs.google.com/open?id=0B8cP4jZuxLlXUmdkcE9lWUtoX3M


Thanks ,
Prateek Shaw




1 comment:

  1. Hi,
    I need to reorder the table columns. But in the database those values are under single field. First i need to get the table horizontally.. Is it possible?

    ReplyDelete