Get Data Table Row in c++

I’ve been trying everything for a long time and I can’t see how this can be done in c++

I’m stuck on passing the name of the structure to variable.( <T* Class> )
I have tried with GetRow<>, But I don’t know how to put a variable instead of the structure name directly.

https://forums.unrealengine.com/core/image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAQAAAAngNWGAAAA/0lEQVR4AYXNMSiEcRyA4cfmGHQbCZIipkuxnJgMStlMNmeyD2dwmc8+sZgxYJd9ErIZFHUyYYD7fkr6l4/rnvmtl7+KitrqV/fq2Y5eLY3Z9S48eRLe7BmVZ9qhTLhQ0algzZWQOVKSsCF8OjAnwbxDTWFDUhPK/jMr1H6HE/IqRky2DyvCefuwItwZzodVoYRiLqMkVCXrwpJ9twZ+sgfDYEFYl8wIWxZ9uFf7zkallxlJh4YrLGsKjZRx7VGHhLqwgFUN45DGdb8MeXGpgB4ABZdeDcpZEY51A+hyLKz4S1W4MQWm3AibWtgWmk6dyISa1pSdyWTOlLXVp0+eL9D/ZPfBTNanAAAAAElFTkSuQmCC

I am assuming that you have a pointer to a UDataTable.
In that case you can simple use :


 FYourStruct* Item = YourDataTable->FindRow<FYoursStruct>(RowName, "");

if you don’t know the RowName or want to iterate all RowNames, use


TArray<FName> RowNames = YourDataTable->GetRowNames();

.

5 Likes

Yeah that’s just what i got.
I want to change <FYourStructName> for a variable like for example: (This is wrong)


 
 FTableRowBase RowBase = DataTable->FindRow<DataTable->RowStructName>(RowName, ContextString); 


That’s not something you can do at all or what is shown in your BP-Screenshot. I do believe that the template parameter has to be known at compile time.
The equivalent to your screenshot is simply:




FName LocalRowName = FDataTableRowHandle.RowName;  
FYourStruct* OutRow = FDataTableRowHandle.DataTable->FindRow<FYourStruct>(LocalRowName, "");


If you want to see how GetDataTableRow is implemented see K2Node_GetDataTableRow.cpp.

ok, understood.
What I don’t understand is why it can be done in Blueprints and in C ++ you have to specify the structure, but hey, if that’s the case, that’s the way it will be.

How do I get the pointer? Just like UDataTable* tableName? BEcause that causes an error for me- DataTable error - C++ - Epic Developer Community Forums
My thread