Skip to main content
12-Amethyst
August 16, 2017
Question

How to insert value to column in Data table

  • August 16, 2017
  • 2 replies
  • 6140 views

I want to create data table but i can't insert to next column how i can do

11111.png

2 replies

17-Peridot
August 16, 2017

you want to insert data in next "ROW" or add new "COLUMN"?

for new "ROW" - use AddDataTablEntries service.

for new Column - Edit its DataShape and add the required one.

Nuttapol12-AmethystAuthor
12-Amethyst
August 16, 2017

I want to add new COLUMN

5-Regular Member
August 16, 2017

Nuttapol Pomtong​ : To add column to your DataTable (DT) you will have to update your DataShape(DS). You can edit the associated DS used by DT and add required field using Field Definitions in DS.

-Durgesh

22-Sapphire I
August 16, 2017

Are you saying you are creating an InfoTable and you want to add a column to that InfoTable?

If so use AddField

If you are actually working with a DataTable, you can only insert what is defined in its datashape.

use Add or AddOrUpdate DataTableEntry (ies)

Nuttapol12-AmethystAuthor
12-Amethyst
August 21, 2017

Do you have any example code for Add or AddOrUpdate DataTableEntry (ies)?

5-Regular Member
August 21, 2017

Nuttapol, are you looking for something like this

Here SpeedDTDemo is my dataTable on which i am doing single entry insert using the AddDataTableEntry service

var values = Things["SpeedDTDemo"].CreateValues();

values.SpeedVal = inputVal; //NUMBER [Primary Key]

var params = {

sourceType: undefined /* STRING */,

values: values /* INFOTABLE*/,

location: undefined /* LOCATION */,

source: undefined /* STRING */,

tags: undefined /* TAGS */

};

// result: STRING

var id = Things["SpeedDTDemo"].AddDataTableEntry(params);

If you are simply testing the service you will not see all the data that has been inserted previous to that particular call, for that you either need to navigate to your Datatable > HomeMashup, like i have shown below in the screenshot, or else you have to query your datatable to see the values that has been inserted so far

Hope this helps.