Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Table Filtering

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

replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question