select multiple currencytextboxes and set value

Dear syncfusion team,

unfortunately i am not able to work with multiple ejcontrols.

I am aware how to work with the model data from a single textbox.
Like:
var mileage = $("#CostsMileage").data("ejNumericTextbox").model.value;
$("#CostsMileage").data("ejNumericTextbox").model.value = 1000;
var lastUpdate = $('#CostsLastUpdate').data("ejDatePicker").getValue();

In my specific case, i have a generic amount of currencytextboxes and i want to set the value for each of them via javascript. 
At first i added a class 'costEntryInput' to the desired controls.

When selecting the controls with $('.costEntryInput'), i retrieve the objects.
Sadly, that's the point where i am stuck. I don't know how to operate on the result array.

When trying to access the ejnummerictextbox with:
$('.costEntryInput').each(function () {
			console.log($(this).ejNumericTextbox('instance').val());
		});
I retrieve the error:
Uncaught ejNumericTextbox: methods/properties can be accessed only after plugin creation
Error: ejNumericTextbox: methods/properties can be accessed only after plugin creation
    at t.throwError (http://localhost:24530/Scripts/ej/web/ej.web.all.min.js:10:29084)
    at jQuery.fn.init.n.fn.(anonymous function) [as ejNumericTextbox] (http://localhost:24530/Scripts/ej/web/ej.web.all.min.js:10:22876)
    at HTMLSpanElement. (:2:24)
    at Function.each (http://localhost:24530/Scripts/jquery-3.2.1.js:362:19)
    at jQuery.fn.init.each (http://localhost:24530/Scripts/jquery-3.2.1.js:157:17)
    at :1:24

Could you please point me to ressouces, which could lead to some hints to solve my issues?



3 Replies

AB Ashokkumar Balasubramanian Syncfusion Team July 3, 2018 10:27 AM UTC

Hi Xaver, 
 
We have checked your reported problem and provided code block at end. For that code block, you have tried to get the value for more than one currency textbox, based on CssClass property. You can set the CssClass for CurrencyTextBox component, it will set it into wrapper element for CurrencyTextBox. So, you can find the corresponding input Element, then create the instance to accessing the methods or properties appropriately. Please check the below modified code block. 
 
[Script] 
 
var currencyElements = document.getElementsByClassName('costEntryInput'); 
for (var a = 0; a < currencyElements.length; a++) { 
    //Create the instance for CurrencyTextBox 
    var obj = $(currencyElements[a].querySelector('.e-currencytextbox')).data('ejCurrencyTextbox') 
    //Get the value for CurrencyTextBox 
    var value = obj.getValue(); 
    console.log("Currency TextBox " + a + " value ---> " + value); 
    //chanage the Currency TextBox value 
    obj.option("value", 20); 
} 
 
For your reference, we have prepared the sample for your requirement, please find the sample in below location. 
Sample:  
 
 
To know more details about API configuration in Syncfusion EJ1 components, please check the below help document. 
 
 
Please let us know, if the provided information’s are helpful to resolve your problem or not. 
 
Regards, 
Ashokkumar B.  



XA Xaver July 3, 2018 12:05 PM UTC

Thank you very much for the fast reploy. This solved my problem!


AB Ashokkumar Balasubramanian Syncfusion Team July 3, 2018 12:30 PM UTC

Hi Xaver, 
 
Most Welcome. 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Ashokkumar B. 


Loader.
Up arrow icon