cancel
Showing results for 
Search instead for 
Did you mean: 

Table Filtering

Former Member
0 Kudos

I have to implement the filter functionality in a table. so I had written this:

IPrivateUDBView.IUDBtableNode UDB_node = wdContext.nodeUDBtable();
int num_ele = UDB_node.size();
		
String itemValue = wdContext.currentContextElement().getFilteritem();
if(ItemValue==null)
	itemValue=".*";

String NameValue = wdContext.currentContextElement().getFilterName();
if(NameValue==null)
	NameValue=".*";
			 			 
String DeptValue = wdContext.currentContextElement().getFilterDept();
if(DeptValue==null)
	DeptValue=".*";
				 
String CompanyValue = wdContext.currentContextElement().getFilterCompany();
if(CompanyValue==null)
	CompanyValue=".*";  
				 
String AreaValue = wdContext.currentContextElement().getFilterArea();
if(AreaValue==null)
	AreaValue=".*";    

if(ItemValue!=".*" || NameValue!=".*" || DeptValue!=".*" || AreaValue!=".*" || CompanyValue!=".*")
{	
    for(int i=num_ele-1;i>=0;i--)
    {
	String UDB_item = (String)UDB_node.getUDBtableElementAt(i).getITEM();    	
	String UDB_name = (String)UDB_node.getUDBtableElementAt(i).getNAME();
	String UDB_Dept = (String)UDB_node.getUDBtableElementAt(i).getDEPT();
	String UDB_Area = (String)UDB_node.getUDBtableElementAt(i).getAREA();
	String UDB_company = (String)UDB_node.getUDBtableElementAt(i).getCOMPANY();
		    	
    if(!UDB_Item.matches(itemValue) || !UDB_name.matches(NameValue)|| 
!UDB_Dept.matches(DeptValue)|| !UDB_Area.matches
(AreaValue)|| !UDB_company.matches(CompanyValue))
    {
    IPrivateUDBView.IUDBtableElement del_element = wdContext.nodeUDBtable().getUDBtableElementAt(i);
    wdContext.nodeUDBtable().removeElement(del_element);    		
    }
    }  
}  	

so, when i click on filter button after giving a value that matches a value in the table,

the corresponding row is displayed. But when I clear the filter value and click on filter button again,

the table goes blank. This happens becos I remove the table elements. how can i filter without

removing the elements? i have tried the blog on filter, but that doesn't work.

I also tried to copy the node elements from another node that had the same table elements.

Even though the copy works, the data is not reflected in the table.

IWDNode TableNode = wdContext.nodeUDBtable();
IWDNode CopyViewNode = wdContext.nodeViewTabNode();
WDCopyService.copyElements(CopyViewNode,TableNode);

please tell me hoe to solve this problem.

Thnx

jack

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jack,

If you have followed this blog

/people/subramanian.venkateswaran2/blog/2005/05/10/filtering-table-values-using-webdynpro

In this blog the data source is custom controller which is mapped to view context so when you delete elements from view context it is not deleted from custom controller context .

So Instead of

IPrivateUDBView.IUDBtableNode UDB_node = wdContext.nodeUDBtable();

int num_ele = UDB_node.size();

you can use

IUDBtableNode UDB_node =

wdThis.wdGet<custom controller>().wdGetContext().nodeUserlist();

int num_ele = UDB_node.size();

Regards,

Rajeev

Message was edited by: Rajeev Ranjan

Former Member
0 Kudos

Hi Rajeev

Thanks for the reply.

I gave the steps in the blog another try and this time it worked perfect.

I have not mapped the conteroller's context to the view table context as mentioned in the blog. so, if i dont map it, it does not display anything on the table initially. but after i do a filter, the matched row is displayed.

in order to make values appear in the table initially, I had done the mapping. when i do the mapping and click on filter button, it throws java.lang.IndexOutOfBoundsException.

However, heres what I need:

1.The table in the view has to be populated with the values that are available in the Controller's Node (say..ControllerTableNode).

2.Once i perform a filter, if there is a match with the filter value, it displays that corresponding row.

3.Now, if i want to clear that filter, and revert to the original state of the table with all the data, how do i do that?

I have implemented step 2. but not able to implement step 1 and 3.

please suggest.

thnx

jack

Message was edited by: jack b

Message was edited by: jack b

Former Member
0 Kudos

Hi Jack,

1. To populate the table with values available in controller node use this code.

IUDBtableNode UDB_node =

wdThis.wdGet<custom controller>().wdGetContext().nodeControllerTableNode();

int num_ele = UDB_node.size();

for(i=inti=0;i<num_ele;i++)

{

IUDBtableNodeElement element=UDB_node.getControllerTableNodeElementAt(i);

element.set<Attribute>();

}

2. Now if you clear the filetr check wether all filter value is null then populate the table with controller data as above

Regards,

Rajeev

Former Member
0 Kudos

Hi:

try:

/people/peter.vignet/blog/2007/01/03/generic-web-dynpro-java-table-filter

regards

Answers (0)