Can I write to a Data Table?

I can READ data from a Data Table…is it possible for me to WRITE to a Data Table?

For example, I have a character roster (with the name of each character). I’d LIKE to give the user the ability to customize the name of a character using an Editable Text Box widget (and submitting it) within a widget blueprint.

However, I can’t figure out how to update an existing data table to accept this edit as the new name.

Any help here?

1 Like

As far as I know you can not modify data table at runtime.

As MMMarcis said - no. In blueprints Data Tables are meant to be static.

But the data table is little more than a map full of structs with a glorious interface :wink: Look into saving game objects; you can save / load the same structs that the DTs are using.

4 Likes

Though you cannot do it from a basic version of unreal there are plugins that allow you to update the data table at runtime by saving to/ reading from a csv.

A data table is for storing info for the editor to use.

If you want to change variables on the fly though you should have it run of structures that all get updated when ever 1 is changed.

For example have a data table set up with all the beginning stats then at “begin play” have an array of structures set using the data table and then have that array updated anytime a player makes a change,

Remember a data table is really just an array of structures

3 Likes

Awesome! this kinda worked for me, I don’t get how the second part is working, but nevermind: I was missing the functionality of accessing the data by row name, so a tip to get that working: Save the array “OutRowNames”, then for access, use “find” → get index of row name → use that to get the correct index from “PlayerInfos”

For everyone looking to write to a Data Table during editor time:

FDataTableEditorUtils::AddRow(UDataTable* DataTable, FName RowName)

shows what you need to do. The important lines are:

FDataTableEditorUtils::BroadcastPreChange(DataTable, EDataTableChangeInfo::RowList);
DataTable->Modify();

// Do your DataTable.AddRow(RowName, SomeNewRow);

FDataTableEditorUtils::BroadcastPostChange(DataTable, EDataTableChangeInfo::RowList);
2 Likes