Dynamically changing Data Table Row Name

Hello!

I want to somehow dynamically change the Row Name of each entry in a Data Table to be the same name of the “item” I create. Is there a way to make that happen?

My struct has another struct of “FItemTextData” which contains the item name. Now in the Data Table I have created I just want the “Row Name” to be changed to the “ItemName”. There has to be a way to do this, I’ve been googling for days and I can’t find a solution. Thank you!

USTRUCT()
struct FItemTextData
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere)
    FName ItemName;

    UPROPERTY(EditAnywhere)
    FText Description;

    UPROPERTY(EditAnywhere)
    FText InteractionText;

    UPROPERTY(EditAnywhere)
    FText UsageText;
};

USTRUCT()
struct FItemData : public FTableRowBase
{
    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere)
    EItemRarity ItemRarity;

    UPROPERTY(EditAnywhere)
    FItemTextData ItemTextData;

    UPROPERTY(EditAnywhere)
    FItemStatsData ItemStatsData;

    UPROPERTY(EditAnywhere)
    FItemInfoData ItemInfoData;
};
1 Like

It’s been a long time, but I had the same problem, and figured it out

virtual void OnDataTableChanged(const UDataTable* InDataTable, const FName InRowName) override
{
	FDataTableEditorUtils::RenameRow(const_cast<UDataTable*>(InDataTable), InRowName, ItemName);
}

You have to add module on your project.Build.cs

if (Target.bBuildEditor)
{
	PrivateDependencyModuleNames.Add("UnrealEd");
}

UnrealEd is an editor-only, so it must be added conditionally

1 Like