cancel
Showing results for 
Search instead for 
Did you mean: 

Sort table columns in a table and context created dinamically

Former Member
0 Kudos

Hello all,

I have implemented the table sorting several times in another developments, but now I'm facing a problem.

I have created the table and context node that I need to sort dinamically (before somebody ask me why, I would say that it's the only way to do that for my current project, there was no possibility of doing that in dessign time). I have implemented the table sorting more or less the same way I would do with a table created in dessing time, but when I run my WD the sorting of columns doesn't work.

In the wdDoModifyView, I have put the following code:

if(firstTime){
....

IWDAction ordenacion	= wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ORDENACION,  null);
IWDParameters param = ordenacion.getActionParameters();
param.addParameter("nombreNodo",nombreNodo);
...

}

and in the code of the action


{
    //@@begin onActionOrdenacion(ServerEvent)
    

	
	System.err.println("**** NOMBRE NODO **** "+nombreNodo);
	wdContext.currentContextElement().getTableSorter().sort(wdEvent, wdContext.getChildNode(nombreNodo, IWDNode.LEAD_SELECTION));
	
    
    //@@end
  }

The name of the node ("nombreNodo) it's only correct the first time I click on a column.

Has anybody implemented the table sorting in a dinamically created table and context node? And how do you do to make it works.

Thank you very much

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Please check these:

Did you create a context attribute (For example: TableSorter) and chage the type of this attribute to the TableSorter java class.

After that you need to write this below code in wdDoModifyView method.

IWDTable table = (IWDTable) view.getElement("Table");
wdContext.currentContextElement().setTableSorter(
new TableSorter(table, ordenacion , null));

Regards,

Charan

Former Member
0 Kudos

Yes, I create the element TableSorter in the context and I also put the code


wdContext.currentContextElement().setTableSorter(new TableSorter(table, ordenacion,null));

in the wdDoModifyView (but I forgot to put it on my first post).

Thanks anyway.

Former Member
0 Kudos

Hi,

Are you getting any complie time / run time error, If yes please post the error?

Are you able to see the sort icon at runtime in your table column header?

What is happening exactly after writing this code??

Regards,

Charan

Former Member
0 Kudos

No, I get no error.

And I see the sort icon in the table header. But when I click on it nothing happens.

As I said before, is an special case, because both the table and the context node bound to the table where created in runtime (dinamically).

Edited by: Mireia Romo on May 27, 2009 1:57 PM

Former Member
0 Kudos

Hi,

Can you check that every time

wdContext.getChildNode(nombreNodo, IWDNode.LEAD_SELECTION)); is returning the proper node.

And

I guess you created this action OrdenAction before writing the piece of code.

IWDAction ordenacion=

wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ORDENACION, null);

So why dont you change the code as below

IWDAction ordenacion=wdThis.wdGetOrdenAction();

Regards,

Charan

Former Member
0 Kudos

Hi,

sorry, I couldn't answer before.

I have done what you have said me, change

IWDAction ordenacion	= wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ORDENACION,  null);

for

IWDAction ordenacion=wdThis.wdGetOrdenacionAction();

Also I have checked the name of the node selected with

wdContext.getChildNode(nombreNodo, IWDNode.LEAD_SELECTION);

The first time I clicked on a column the name of the node is correct, from so on a null is returned. Also I have stated that when I clicked on the arrows of a column, the arrows dissappaered.

Former Member
0 Kudos

Hi,

Can you please post the piece of code you wrote in wdDoModifyView() method for this particular functionality.

As per the runtime behaviour you told I guess theres is some issue because of writing some code in if(firsttime).

Regards,

Charan

Former Member
0 Kudos

Here is the code



//Preparamos Navegaciones
						
IWDAction abrirProyecto = wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ABRIR_PROYECTO, null);
IWDAction abrirDisp	= wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ABRIR_DISPONIBLE,  null);
						
//IWDAction ordenacion	= wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ORDENACION,  null);
IWDAction ordenacion=wdThis.wdGetOrdenacionAction();
IWDParameters param = ordenacion.getActionParameters();
param.addParameter("nombreNodo",nombreNodo);
					
						
						
IWDTable table = wdThis.wdGetInformesController().crearTabla(view, nombreNodo, movimientosInfo,new String[]{"Codi Projecte",null,"Nom Projecte", "Import Projecte", "Client", "Increment Disponible futur per facturació no emesa i / o anualitats pendents","Increment Disponible futur per ingressos pendents de cobrar", "Disponible"},new String[]{"10px", null,"10px", "10px","10px","10px","10px","10px"},new IWDAction[]{abrirProyecto,null, null, null, null,null,null,abrirDisp}, -1);
						
//ordenar tabla
						
						
wdContext.currentContextElement().setTableSorter(new TableSorter(table, ordenacion,null));
						
containerTablasProyecto.addChild(table);



Edited by: Mireia Romo on May 28, 2009 12:27 PM

Former Member
0 Kudos

Hi,

Sorry I am not sure why it is failing:

Can you pls try doing the below functionality before if(firsttime);

creating the node & action and adding the node as parameter to action.

And is it working for the firsttime? Is sorting of data is happening for the firsttime?

Regards,

Charan

Former Member
0 Kudos

Sorry, I can't create the node outside the if(firsTime) because for the complexity of the project I don't know beforehand how many nodes I need to create and if I create it beforehand I get a namingException (duplicate name of the node).

Anyway, the first time I click for sorting the table doesn't work neither.

Edited by: Mireia Romo on May 28, 2009 1:02 PM