You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

fetch value from grid and show that as prompt

6 replies [Last post]
P I Y A L I's picture
User offline. Last seen 11 years 44 weeks ago. Offline
Joined: 02/25/2008
Posts: 12

Hi,

How to fetch value from Grid and show those as drop down to another field.

Thanks
Piyali

Warm Regards,
P I Y A L I

CompShack's picture
User offline. Last seen 6 years 8 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Re: fetch value from grid and show that as prompt

Hi Piyali - nice to see you again :)
I have a blog post that shows how you do a similar thing. The post shows how to fetch a value from a grid, the thing that you need to do differently is store the values fetched to an array. After you finished fetching all the values you need you can then populate the drop down list using the rest of the code in the post.

Pay attention to the last part:

/* Clear drop down list and then show only "Home" */
   DERIVED_CO.ADDR_TYPE_DESCR.ClearDropDownList();
   DERIVED_CO.ADDR_TYPE_DESCR.AddDropDownItem("HOME", "Home");

You will need to do some work here to figure out how to pass the values in your array. One way is to loop through the values and pass them in to the AddDropDownItem function.

Good luck!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Deepak's picture
Deepak (not verified)
Re: fetch value from grid and show that as prompt

Make a For loop to read the rowset of that Grid while looping using
adddropdownlist function to add the values in the field to make that drop down value.

Ex:
&rs=getlevel(0)().getrecord(1).getscroll(Scroll. Grid Name);
For &i=1 to &rs.activerowcount
Adddropdownlist(Record.Field ,&rs(&i).Record.Record name.Field.Field Name.Value);
End-for;

All the best

CompShack's picture
User offline. Last seen 6 years 8 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Re: fetch value from grid and show that as prompt

This might help you get it done without using an array ;)
Thanks Deepak!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

P I Y A L I's picture
User offline. Last seen 11 years 44 weeks ago. Offline
Joined: 02/25/2008
Posts: 12
Re: fetch value from grid and show that as prompt

Thanks A lot Comshack and Deepak,

I have succeeded to add those value in drop down.

But still one problem.That drop down is not getting cleared at second attempt.It is holding the previous value.I Have added ClearDropList.But Still Its not working.

Here is the code which i have written in Page Activate.

************************************************
&rs1 = GetLevel0().GetRow(1).GetRowset(Scroll.COMPETENCIES);

&fld1 = &rs1.Getrow(1).GetRecord(Record.COMPETENCIES).GetField(Field.HX_PRIMARY);

&fld2 = &rs1.Getrow(1).GetRecord(Record.COMPETENCIES).GetField(Field.HX_SECONDARY);

&fld1.ClearDropDownList();

&fld2.ClearDropDownList();

&SQLCust = CreateSQL("Select COMPETENCY FROM PS_COMPETENCIES WHERE EMPLID=:1", CM_EVALUATIONS.EMPLID);
&SQLCust1 = CreateSQL("Select COMPETENCY FROM PS_COMPETENCIES WHERE EMPLID=:1", CM_EVALUATIONS.EMPLID);

While &SQLCust.Fetch(&COMPETENCY1)

&fld1.AddDropDownItem(&COMPETENCY1, &COMPETENCY1);

End-While;

While &SQLCust1.Fetch(&COMPETENCY1)

&fld2.AddDropDownItem(&COMPETENCY1, &COMPETENCY1);

End-While;
***********************************************

Warm Regards,
P I Y A L I

Warm Regards,
P I Y A L I

CompShack's picture
User offline. Last seen 6 years 8 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Re: fetch value from grid and show that as prompt

But still one problem.That drop down is not getting cleared at second attempt.It is holding the previous value.I Have added ClearDropList.But Still Its not working.

Here is the code which i have written in Page Activate.

Page activate code fires once and only once (when the page loads). How are you going about your 2nd attempt? are you exiting the page and coming back? or do you just have an emplid field on the page and you change that to change the drop down values?

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Ashar's picture
User offline. Last seen 4 years 39 weeks ago. Offline
Joined: 03/26/2008
Posts: 227
Re: fetch value from grid and show that as prompt

The best way would be to put this piece of code in a function and call the function whenever you would require to reload the drop down list.

Peace,

Ashar