hello
please help me!
i have an numeric editor. i want to change value on event keydown but i don't know how to
here is my code
$(document).delegate("#cpsngIssueAmt", "ignumericeditorkeydown", function (evt, ui) { var code = evt.originalEvent.keyCode; if (code == 77) { var tmpValue = $("#" + ui.owner.options.inputName).igNumericEditor('value'); if (tmpValue != undefined && tmpValue != null && tmpValue != "") { $("#" + ui.owner.options.inputName).igNumericEditor('value', tmpValue * 1000); } } });
i wish when user press 'm' and then i set the numeric editor value = current value * 1000. but nothing happends
can you help me
thank you very much!
Hello Cuong Tran,
Thank you for posting in our forums!
After researching this some, there is an issue with updating the display in the editor correctly. In our newer bi-weekly builds this issue has been resolved. If you would like to use our latest bi-weekly build until the next service release is available, you can download it here:
http://builds.infragistics.com/products/IgniteUI/2015.2/IgniteUI_20152.2146_SR.zip* Please note that our bi-weekly builds are provided between Service Releases and they are not fully regression tested and are not recommended to be used in production environments.
The one thing in your code I noticed I would recommend changing is using ui.owner.element instead of $("#" + ui.owner.options.inputName). The ui.owner.element argument is the jQuery object for the editor and is less error-prone than using the inputName option. You can see an example of how I use this below:
$(document).delegate("#cpsngIssueAmt", "ignumericeditorkeydown", function (evt, ui) { var tmpValue, code = ui.key; if (code == 77) { tmpValue = ui.owner.element.igNumericEditor('value'); if (tmpValue != undefined && tmpValue != null && tmpValue != "") { ui.owner.element.igNumericEditor('value', tmpValue * 1000); } }});
If you have any further questions or concerns with this, please let me know.
Sorry but it could not work. i pressed 'm' but nothing happened
can you re-test it, please
thanks you very much!
Hi Cuong Tran,
Please make sure you are referencing the 15.2.20152.2146 scripts after installing the bi-weekly build.
I have attached a working sample that references the 15.2.20152.2146 scripts. When I open the page, I click in the igNumericEditor to give focus to the widget. Then, I press "M" and the value changes from 5 to 5000.
If you need further assistance with this, please let me know.
thanks you very much.
it works fine after the newest vesion was instaled
but i saw another problem.
after i press 'm' then i changes value to other number and then i recieve the previous number after i pressed 'm'
example
i enter 5 then press m. then i remove all number then i press 6 then i press m. i will recieve 5000000. are there some thing wrong?
thank for your helper.
I've modified my sample using 15.2.2146 and using the code you provided, I am not seeing the behavior you are describing.
In my sample, I have two igNumericEditors with your two code samples handling the key down event. When I run the page, I press "m" while focused on each igNumericEditor and they both display as "5,000".
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using version 15.2.20152.2146 in Ignite UI 2015 Volume 2.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
i wrote
var numberHelper = { Generate3ZeroChar: function (evt, ui) { var tmpValue, code = ui.key; if (code == 77) { ui.owner.element.blur(); ui.owner.element.focus(); setTimeout(function () { //tmpValue = ui.owner.element.igNumericEditor('value'); tmpValue = ui.owner.element.igNumericEditor('field').val(); if (tmpValue != undefined && tmpValue != null && tmpValue != "") { ui.owner.element.igNumericEditor('value', tmpValue * 1000); } }, 0); return false; } }}
and i called
$.ig.loader(function () { $(document).delegate(".tpg-numeric-editor", "ignumericeditorkeydown", function (evt, ui) { numberHelper.Generate3ZeroChar(evt, ui); });});
it still generated 000 000
but when i wrote
var numberHelper = { Generate3ZeroChar: function (evt, ui) { var tmpValue, code = ui.key; if (code == 77) { ui.owner.element.blur(); ui.owner.element.focus(); setTimeout(function () { //tmpValue = ui.owner.element.igNumericEditor('value'); tmpValue = ui.owner.element.igNumericEditor('field').val(); if (tmpValue != undefined && tmpValue != null && tmpValue != "") { ui.owner.element.igNumericEditor('value', tmpValue * 1000); } }, 0); } }}
$.ig.loader(function () { $(document).delegate(".tpg-numeric-editor", "ignumericeditorkeydown", function (evt, ui) { numberHelper.Generate3ZeroChar(evt, ui); var code = ui.key; if (code == 77) return false; });});
it works ok! i generated right 000.
what are different from its?
I do not understand what you are saying. Could you please clarify what you are referring to when saying "i write return = false to skip the generate 000 from build-in function. but nothing happened. it is still generate 000000."
Also as a side note, with Todor's solution you do not need to call focus, blur, or setTimeout. You can use the following code:
var tmpValue, code = ui.key;if (code == 77) { tmpValue = ui.owner.element.igNumericEditor('field').val(); if (tmpValue != undefined && tmpValue != null && tmpValue != "") { ui.owner.element.igNumericEditor('value', tmpValue * 1000); } return false;}
Looking forward to hearing from you.
it works fine. thanks you very much.
But if i write this code to specific function. i write return = false to skip the generate 000 from build-in function. but nothing happened. it is still generate 000000
var tmpValue, code = ui.key; if (code == 77) { ui.owner.element.blur(); ui.owner.element.focus(); setTimeout(function () { //tmpValue = ui.owner.element.igNumericEditor('value'); tmpValue = ui.owner.element.igNumericEditor('field').val(); if (tmpValue != undefined && tmpValue != null && tmpValue != "") { ui.owner.element.igNumericEditor('value', tmpValue * 1000); } }, 0); return false; }
thank you
When you enter the edit mode and type 8 it's still not the value of the editor, but just the edit value when you call the value API method it still returns 5. and when multiplied by 1000 it's correctly calculated 5000. Instead you can use tmpValue = ui.owner.element.igNumericEditor('field').val() - which will return you the current text inside the input. And then the multiplied value should be as you expect.
Hope that helps.
Thanks,