Dropdown getNewItem @ItHurtsWhenIThink

21 views
Skip to first unread message

Dai bok

unread,
Oct 2, 2010, 7:09:00 AM10/2/10
to asp-ajaxed
Hi Mike,

Just moving your question into a seprate thread. From the look of
things, the getnewitem just creates and returns an instance of a
dropdown item. It does not add this item to the datasource of dropdown
items. I think that is what are expecting it to do?

(I am on my mac now, and don't have access to windows to test things
out, so I will try help if I can)

I am guessing that you do somthing like this instead:
...
set ddItem = myDD.getNewItem("12345","Wayne Jones")
ddItem.draw()
...

Let me know if that helps?
(note to self - must get bootcamp working!)


On Oct 1, 8:30 pm, ItHurtsWhenIThink <madiaz91...@gmail.com> wrote:
> Speaking of dropdown, can you please take a look at the following
> example and tell me why this code will not add a new dropdown item?
>
> >>>>> DD <<<<<<<<<<<<<<
>
> sub drawDD()
> with new Dropdown
> 'you can also use SQL, Dictionary, ...
> .datasource = array("Jack Johnson", "John Meyer")
> .name = "myDD"
>
> '##############################################################################################################
> '###### I keep getting errors right here "cannot use parethesis
> in sub" I remove them but dropdown will not add new item #########
> .getNewItem("12345","Wayne Jones")
>
> '##############################################################################################################
> .multiple = page.QS("t") <> ""
> if .multiple then .size = 2
> if page.QS("t") = "multipleS" then
> .multipleSelectionType = DD_SELECTIONTYPE_SINGLE
> .size = 50
> elseif page.QS("t") = "multipleM" then
> .multipleSelectionType = DD_SELECTIONTYPE_MULTIPLE
> .size = 50
> end if
>
> .draw()
> end with
> end sub
>
> Thanks,
>
> Mike....
>

ItHurtsWhenIThink

unread,
Oct 4, 2010, 1:41:41 AM10/4/10
to asp-ajaxed
The dropdown list is taken from a databse. I need to add an item to
the dropdown list (first item). You know when you want to aloow a user
to modify a record with data from a db table, but you need to have the
first item in the dropdown list the value of the current record they
are modifing. That is what I am trying to do.

Here is a chunck of code I am using. Just need to add an item to
dropdown list (first item on list).

Sub pagepart_getOSInstructor
with new Dropdown
Set .datasource = db.getUnlockedRS("Select FName + ' ' + LName AS
Instructor, UserID FROM Users AS U, tr_Instructors AS T Where
T.InstructorID=U.UserID AND T.DeptID='{0}' AND U.Enable='Yes'",
Request.Cookies("DeptID"))
.dataTextField = "Instructor"
.dataValueField = "UserID"
.commonFieldText = "-- Instructor --"
.name = "frmInstructor"
'######## liie to add list item #######
' HOW DO I ADD NEW ITEM i.e.,
.getNewItem("12345","Wayne Jones") ' THIS DOES NOT WORK
'##############################
.onItemCreated = "onEncript"
.attributes = "onchange=""ajaxed.callback('getTeacher',
'Instructor')"""
.draw()
end with
End Sub

So, How do I get a new dropdown item to show up.

Thanks,

Mike....

On Oct 2, 4:09 am, Dai bok <rankin...@gmail.com> wrote:
> Hi Mike,
>
> Just moving your question into a seprate thread. From the look of
> things, the getnewitem just creates and returns an instance of a
> dropdown item. It does not add this item to the datasource of dropdown
> items. I think that is what are expecting it to do?
>
> (I am on my mac now, and don't have access to windows to test things
> out, so I will try help if I can)
>
> I am guessing that you do somthing like this instead:
> ...
> set ddItem = myDD.getNewItem("12345","Wayne Jones")
> ddItem.draw()
> ...
>
> Let me know if that helps?
> (note to self - must get bootcamp working!)
>
> On Oct 1, 8:30 pm, ItHurtsWhenIThink <madiaz91...@gmail.com> wrote:> Speaking of dropdown, can you please take a look at the following
> > example and tell me why this code will not add a new dropdown item?
>
> > >>>>>  DD <<<<<<<<<<<<<<
>
> > sub drawDD()
> >   with new Dropdown
> >     'you can also use SQL, Dictionary, ...
> >     .datasource = array("Jack Johnson", "John Meyer")
> >     .name = "myDD"
>
> > '##########################################################################­####################################
> >      '######  I keep getting errors right here "cannot use parethesis
> > in sub"  I remove them but dropdown will not add new item #########
> >     .getNewItem("12345","Wayne Jones")
>
> > '##########################################################################­####################################

Dai bok

unread,
Oct 4, 2010, 7:40:04 AM10/4/10
to asp-ajaxed
Hi Mike,

I had a look at this, and found a problem. when you fisrt set the
datasource, using db.getUnlockedRS, the dropdown uses record set as
its data source. When using getNewItem,
this changes the datasource to a type of array, that is why we get
problems. Its probably not a good idea to have a dropdown with
mutliple type for datasources, but thats just my opinion.

A simple solution I got working was to do a union in my sql string:
something like this in MySQL:

Set .datasource = db.getUnlockedRS("Select concat(first_name, ' ',
last_name) AS fullname, user_id FROM users UNION SELECT 'wayne jones',
12345 ", empty )

I guess yours would like something like:
Set .datasource = db.getUnlockedRS("Select FName + ' ' + LName AS
Instructor, UserID FROM Users AS U, tr_Instructors AS T Where
T.InstructorID=U.UserID AND T.DeptID='{0}' AND U.Enable='Yes' UNION
SELECT 'Wayne Jones',12345 ", Request.Cookies("DeptID"))

Let me know if that helps?

ItHurtsWhenIThink

unread,
Oct 5, 2010, 4:34:54 PM10/5/10
to asp-ajaxed
Thank you very much. I will play with that solution in a day or so.
I'm sure your solutuion will work. Again, thank you.

Mike....
Reply all
Reply to author
Forward
0 new messages