cancel
Showing results for 
Search instead for 
Did you mean: 

filtering data in the table

former_member187658
Participant
0 Kudos

Hi

I have to apply filter functionality to my table.

For that i searched on SDN and found a blog.

I wrote the code similar to it.

But when i ran my application, it doesnt filter the data, and rather on giving the filter parameter and clicking, the already present data in the table disappears.

The code i wrote is as follows:

ICmpNode_CodeNode values=wdThis.wdGetCustomerBACodeSelectionCompController().wdGetContext().nodeCmpNode_Code();

int n = values.size();

String filterValue = wdContext.currentContextElement().getCtx_FilterValue();

int numberOfElements = wdContext.nodeCtxNode_Code().size();

wdComponentAPI.getMessageManager().reportSuccess("numberOfElements:"+numberOfElements);

for (int i = numberOfElements - 1; i >= 0; i--)

{

IPrivateCustomerBACodeSelectionView.ICtxNode_CodeElement myElement = wdContext.nodeCtxNode_Code().getCtxNode_CodeElementAt(i);

wdComponentAPI.getMessageManager().reportSuccess("myElement:"+myElement);

wdContext.nodeCtxNode_Code().removeElement(myElement);

}

for (int i = n - 1; i >= 0; i--)

{

String value = (String) values.getCmpNode_CodeElementAt(i).getAttributeValue("Org_Code");

if (value.matches(filterValue))

{

IPrivateCustomerBACodeSelectionView.ICtxNode_CodeElement newElement=wdContext.nodeCtxNode_Code().createCtxNode_CodeElement();

newElement.setCmp_OrgCode((String) values.getElementAt(i).getAttributeValue("Org_Code"));

newElement.setCmp_Description((String) values.getElementAt(i).getAttributeValue("Description"));

wdContext.nodeCtxNode_Code().addElement(newElement);

}

}

}catch(Exception ex)

{

ex.printStackTrace();

}

Thanks & regards,

Anupreet

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Anupreet,

Are you sure you whant RegExp (regular expression) matching here?

if (value.matches(filterValue))

Try your existing application with the following filters:

.*

/^a.*$/

first displays everything, other one only elements starting with "a" letter

Does your code works?

VS

Former Member
0 Kudos

Hi,

Is there any other ways of acheiving filtering ..?

As per the weblog , we have to delete the elements each time and re-create them for each search.. which does not seem to be very efficient ?

Plus.. In case , I have mapped the nodes I cant delete and re-create them .. (as the controller data wil also be lost ?)

SO.. Any other workarounds for filtering.. ?

Regards

Bharathwaj

Former Member
0 Kudos

Bharathwaj,

There is no other way to filter except adding / removing node elements.

Model nodes are internally well-optimized from memory consumption prospective: actually, they do not hold attributes themself, but rather delegate call to model objects.

Also, if model uses ICMIObservableList for object collections based on CMI models (ESF, CAF service modules), then nodes even do not copy model object references.

So, in fact, model node is quite light-wight adapter.

VS

Former Member
0 Kudos

Hi:

try:

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

regards

Former Member
0 Kudos

Hi Anupreet,

The problem may be in the attribute cardinality of the node for the filter attributes. Try changing it from 0..n to 1..1.

Hope this should solve ur problem,

Regards,

Nagarajan.

former_member187658
Participant
0 Kudos

Hi Nagarajan,

I tried changing the cardinality, but still the same problem is coming.

Thanks & regards,

Anupreet

Former Member
0 Kudos

Hi Anupreet,

Did u check this blog.This should help u

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

Hope this helps u,

Regards,

Nagarajan.

former_member187658
Participant
0 Kudos

Hi nagarajan,

This is the weblog i was referring to in my post. I checked this weblog and then only i wrote the similar code in my application, as that is exactly what i require. But it didn't work and presented the issues i mentioned above.

I tried commenting the code written for removing the data and then ran the application. In this scenario, the filtering doesn't happen and the already present data remains displayed in the table.

I am not able to figure out what exactly the issue is.

Thanks & regards,

Anupreet