cancel
Showing results for 
Search instead for 
Did you mean: 

fetching more than one row from a table after selecting one value from the dropdown

Former Member
0 Kudos

Hi Experts,

How can we fetch more than one row from a table after selecting one value from the dropdown.

The scenario is that I have some entries in the dropdown like below

  A               B               C        

11256          VID          911256  

11256          VID          811256

11256          SONY      11256

The 'B' values are there in the dropdown. I have removed the duplicate entries from the dropdown so now the dropdownlist has only two values.for eg- 'VID' and'SONY'. So now, after selecting 'VID' from the dropdown I should get all the 'C' values. After this the "C' values are to be passed to other methods to fetch some data from other tables.

Request your help on this.

Thanks,

Preeetam Narkhede.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi preetam...

1. you can create a local node with same structure than...

2. copy original data to local node

3. invalide original node .

4. select value from dropdown (create action on select)

5. loop the data with selected value and add rows in original node

6. whenever you select values from dropdown follow steps (3,4,5).

Thanks and best reagrds

Aasif Shah

former_member82178
Active Participant
0 Kudos

Hi Preetam,

I would think out of box solution as using collections (ArrayList/Hashmap) to load drop down values for column 'B' as key and column 'C' as value. Using collections API to get required values based on key to pass to other methods.

Thanks & Regards,

Madhu Sudhan

Former Member
0 Kudos

Hi Madhu Sudhan,

Can you please explain me this in detail. I am new to this so did not get what you said.

It will be much helpful if you can explain this with an example.

Request your help on this.

Thanks,

Preetam Narkhede

michael_voss2
Participant
0 Kudos

Hi Preetam!

I hope I understand your request proberly, since this is more about Java and less about WebDynpro, but if I'm wrong, just follow up on this.

Supposed you have some collection of your original table data stored in variable "origin". Populate a Hashtable using the values from column "B" (let's assume it's Strings) as keys and an ArrayList of whatever "C" is (let's assume String instances, too) as value (there's a lot of ways to iterate over whatever your datasource is, and since we do not know what your datasource is, maybe you'll have to follow another approach to get b and c vaues,but the principle should remain the same):

// Declare a private variable for your Data at the appropriate place in your code

private Hashtable temp = new Hashtable<String, ArrayList<String>>();

[...]

// Then, in the method you use to retrieve backend data and populate the dropdown,

// populate the Hashtable, too

[...]

Iterator<TableData> a = origin.iterator();

while (a.hasNext()) {

     TableData current = a.next();

     String b = current.getB();

     String c = current.getC();

     ArrayList<String> values = this.temp.get(b);

     if (values == null) {

          values = new ArrayList<String>();

     };

     values.add(c);

     this.temp.put(b, values);

}

So after this, you'll have a Hashtable with the B values als keys and collections of C values of this particular B as value:

VID --> (911256, 811256)

SONY --> (11256)

Use

temp.keySet()

to populate your dropdown.

After the user selects an entry from the dropdown (let's say stored in variable selectedB), you will be able to retrieve the collection of c's from your Hashtable

// In the metod you handle the selection event with, get the c value collection

//and use it to select from your other table

ArrayList<String> selectedCs = this.temp.get(selectedB);

// now iterate over the selectedCs items and use each of these

//to continue retrieving whatever data you need...

for (String oneC : selectedCs) {

     // Select Data from backend using oneC in the where-Clause or whatever...

}

Hope that helps

Michael