Pete Nellmapius
Posts: 0
Joined: Thu Sep 05, 2013 1:24 pm

Access dynamic created Input Control that is selected by a user.

I have a Grid with 2 columns. The first contains a label and the second an input control (number).
The grid is connected to a datasource and the label to a field in the datasource. The Input controll is not connected.
When the Datasource is Invoked the Grid expands to contain all the records.
I want to evaluate the Input control's value on the 'Value Change' event when the user types in a value.
I also want to loop through the input controls which would be an array of controls and retrieve the values in them.
Can anyone help me.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Access dynamic created Input Control that is selected by a user.

Hello!
<[quote:]I want to evaluate the Input control's value on the 'Value Change' event when the user types in a value.[/quote]
If you added "Value change" event for Input component which is inside Grid then you would need to use the following JS:
codevar inputValue = $(this)&#46;val();/code
[quote:]I also want to loop through the input controls which would be an array of controls and retrieve the values in them. [/quote]
to retrieve array from Input components:
codevar valuesArray = [];

$("[name=gridComponentName]:visible")&#46;find("input")&#46;each(function(){
valuesArray&#46;push($(this)&#46;val());
});/code
gridComponentName - name of Grid component which is mapped to array
After you invoke this code into "valuesArray" array will be saved values of all Input components.

Pete Nellmapius
Posts: 0
Joined: Thu Sep 05, 2013 1:24 pm

Access dynamic created Input Control that is selected by a user.

Thanks Marina
Now my Input Control is set to type 'number' but I can still enter any character type.
Is there a way to force numeric input only and say between 0 and 3

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Access dynamic created Input Control that is selected by a user.

Hi Pete,

Simplest solution is use KeyPress Event with code like this:

prevar code = arguments[0]&#46;charCode;
if (code < 48 || code > 58) { &#47;&#47; codes from 48 to 58 describe 0&#46;&#46;9
arguments[0]&#46;preventDefault();
}/pre

But, user still can paste text to the field from clipboard. So you can try use Value Change event to check full value ( Appery( "mobileinput_name" ).val() ).

Pete Nellmapius
Posts: 0
Joined: Thu Sep 05, 2013 1:24 pm

Access dynamic created Input Control that is selected by a user.

Thanks Anton
On the 'Value Change' event I evaluate the value as you showed above.That's great.
The user may click into another field that fires the Change event.
How do I set the focus back to the input control I've just evaluated?

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Access dynamic created Input Control that is selected by a user.

preAppery( "mobileinput_name" )&#46;get(0)&#46;focus();/pre This code will set focus to input field with name mobileinput_name.

Pete Nellmapius
Posts: 0
Joined: Thu Sep 05, 2013 1:24 pm

Access dynamic created Input Control that is selected by a user.

That does not help me because I do not know the input field's name
Look at the top of this thread:

here is my code:
var inputValue = $(this).val();
inputValue = parseInt(inputValue);

if (Math.floor(inputValue) == inputValue) {
if (inputValue < 0 || inputValue 5) {
alert("Value must be between 0 and 5")
$(this).val(null);
$(this).focus();
};
}

$(this).focus(); does not change the focus;
This is not critical but would be great to be able to do this.

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Access dynamic created Input Control that is selected by a user.

Ok, sorry,

Try this: pre$(this)&#46;get(0)&#46;focus();/pre

Pete Nellmapius
Posts: 0
Joined: Thu Sep 05, 2013 1:24 pm

Access dynamic created Input Control that is selected by a user.

I did try that but it also does not change the focus.

Return to “Issues”