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!
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.
hi
another problem
on initially if value of editor = 0 or = null then enter the value after that press 'm' then i save 0 value
thanks you
I have created a support case for you with an ID of CAS-170654-F6S2N0. The matter has been determined to be a development issue and has been logged in our tracking system with ID: 215590.
I will leave this case open and update you with any new information. You can view the status of the development issue connected to this case by going to the “Account” tab on our website, selecting "My Support Activity" and then this support case will be listed there. Then, you may select the "Development Issues" tab to view details of this development issue.
As a temporary workaround, you can call blur() and focus() to update the value, then use a setTimeout with a delay of 0 milliseconds to get the correct value. See the following code for example:
$(document).delegate("#editor", "ignumericeditorkeydown", 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'); if (tmpValue != undefined && tmpValue != null && tmpValue != "") { ui.owner.element.igNumericEditor('value', tmpValue * 1000); } }, 0); }});
Please let me know if you have any questions.
sorry
you did not understand my problem
i describe it again
please get clearly
following your suggestion in the previous artical i upgated to 15.2.2146. and that function had existed in you libradry so i remove my code from event 'ignumericeditorkeydown'. i don't need any code to generate 000. and it work fine but have some problem
1. if the editor is nothing or =0. after that i enter a number and then i press m but it return the value 0
2. i assume that i have 5000. then i enter another number to the editor ex: 6. now, value of editor is 6. then i press 'm'. now, value in the editor is 5000000?
please tell me how to fix this problem.
Hi Cuong Tran,
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,
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