cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How can I change data type and add entries of a Column of infotable?

njain-31
5-Regular Member

How can I change data type and add entries of a Column of infotable?

I have service with output as Infotable, of which one of the column (Temperature) has some values but data type is String. How can I change Data Type of all the values and then add all the values.

1 ACCEPTED SOLUTION

Accepted Solutions
amittal-3
13-Aquamarine
(To:njain-31)

Hi Nikhil,

Understood your problem!!!. Well in that case you can use "Number()" of javascript. It can be used as follows, here I am converting a value formatted in string to just number.

 

var arr = { };
//for loop to get the values from your infotable
for(var i = 0; i < myInfoTable.getRowCount(); i++)
{
	arr[i] = Number(myInfoTable.getRow(i).Temperature);  //Assuming that you have a column named as 'Temperature' in your infotable
}

I hope this helps

Thanks and Regards

Aditya Mittal

View solution in original post

3 REPLIES 3
amittal-3
13-Aquamarine
(To:njain-31)

Hello,

I am sorry as I am not able to understand your requirement clearly.

But I'll try to put it in my words what I understood. So you have a infotable with one of its field of name Temperature of type string. Now while filling that infotable you would want to fill that 'Temperature' column with values of type string, for that you would need a mechanism to convert the actual temperature values (which actually are of number type) to string and then put it in the infotable. Is that understanding correct?

If this understanding is correct then simply when you are filling your infotable, instead of putting the values directly in the 'Temperature' field, you can use num.toString() method.

 

var temperatureVariable; //of type Number
//for loop to add rows to your infotable consecutively 
myInfotable.AddRow(
    {
        Temperature: temperatureVariable.toString()
    })

Let me know if it helps.

Thanks

Aditya

njain-31
5-Regular Member
(To:amittal-3)

Hi Aditya,

 

Thanks for your response. I want to change data type other way around, value of Temperature is in String Data type in my current infotable which I need to change it in Number.

 

Thank You

 

Nikhil 

amittal-3
13-Aquamarine
(To:njain-31)

Hi Nikhil,

Understood your problem!!!. Well in that case you can use "Number()" of javascript. It can be used as follows, here I am converting a value formatted in string to just number.

 

var arr = { };
//for loop to get the values from your infotable
for(var i = 0; i < myInfoTable.getRowCount(); i++)
{
	arr[i] = Number(myInfoTable.getRow(i).Temperature);  //Assuming that you have a column named as 'Temperature' in your infotable
}

I hope this helps

Thanks and Regards

Aditya Mittal

Top Tags