PDA

View Full Version : Triggering a constrain from a checkbox



Anders Ohrt
3-Apr-2007, 02:06 AM
I've begun experimenting with the Ajax library now, and I want to add a
constrain depending on a checkbox (like "Only active records"). In the
Contact Management example there is something similar, but this doesn't
reconstrain "on the fly", just the next find. I though I'd add an "onchange"
function to the checkbox, but is there already some function I should call,
or should I copy something like doFind and adapt it for my needs? It feels
like this will be a very common operation, so I didn't want to reinvent the
wheel too many times. =)

// Anders

Anders Ohrt
3-Apr-2007, 02:19 AM
> I've begun experimenting with the Ajax library now, and I want to add a
> constrain depending on a checkbox (like "Only active records"). In the
> Contact Management example there is something similar, but this doesn't
> reconstrain "on the fly", just the next find. I though I'd add an
> "onchange" function to the checkbox, but is there already some function I
> should call, or should I copy something like doFind and adapt it for my
> needs? It feels like this will be a very common operation, so I didn't
> want to reinvent the wheel too many times. =)

Once you post to a newsgroup, you always figure out the solution within 15
minutes. I found the refresh() call in the grid, so
'onchange="getVdfControl('<%=vdfMainTable%>_lookup').refresh();"' works
great.

// Anders

Hans van de Laar
3-Apr-2007, 03:11 AM
Anders Vhrt wrote:

> onchange="getVdfControl('<%=vdfMainTable%>_lookup').refresh();"'
> works great.

Hi Anders,

Where exactly did you add this onChange code?

--
Regards,

Hans van de Laar
Micros b.v.
The Netherlands
www.micros.nl

Anders Ohrt
3-Apr-2007, 03:34 AM
>> onchange="getVdfControl('<%=vdfMainTable%>_lookup').refresh();"'
>> works great.
>
> Where exactly did you add this onChange code?

At first, I put it my checkbox directly. Now I've put it into it's own
method, since I will probably add a "loading" screen or something:

function RefreshList(){
getVdfControl('<%=vdfMainTable%>_lookup').refresh();
}

<input type="checkbox" name="heat_resistant" value="True"
onchange="RefreshList();" />

// Anders

Hans van de Laar
3-Apr-2007, 05:53 AM
Hi Anders,

Did you added the modification to the latest sample? I can't get it to
work.
Where is your '<%=vdfMainTable%>_lookup' defined?

--
Regards,

Hans van de Laar
Micros b.v.
The Netherlands
www.micros.nl

Anders Ohrt
3-Apr-2007, 08:33 AM
> Did you added the modification to the latest sample? I can't get it to
> work.
> Where is your '<%=vdfMainTable%>_lookup' defined?

My page is based on the Ajax List template (from Beta 1), so there is a
table with vdfControlName="<%=vdfMainTable%>_lookup". Check the search
button, it contains
'onclick="getVdfControl('<%=vdfMainTable%>_lookup').jumpIntoListDisplay();"',
so I just copied that and changed onclick to onchange, and
jumpIntoListDisplay() to refresh() and it worked.

// Anders

Hans van de Laar
3-Apr-2007, 09:08 AM
Hi Anders,

Thanks, that clarifies a bit. I supposed you had added the code to the
internal lookup list of the contacts.asp.

--
Regards,

Hans van de Laar
Micros b.v.
The Netherlands
www.micros.nl