Julian,
Widget properties will allow you to do this. In your properties, create some dropdowns with your custom table values (static or dynamic). Then in your controller, get the value the user selected and execute your code.
In your compenent viewmodel/controller do something like this:
if (!string.IsNullOrEmpty(viewModel.Properties.CustomTableName))
{
// check to see if the custom table exists in the system.
DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
if (customTable != null)
{
// this is where it gets interesting, you need to switch through the custom table object names to determine what DTO you'll call to get your strongly typed data back OR you can create a generic custom table item class that does the transformation of data from your custom table object to a generic object for each of the custom table classes (up to you).
switch (customTable.ClassName.ToLower())
{
case "customtable.Table1":
// call your DTO for the customtable.Table1 object
var ct1Model = CustomTable1ViewModel.GetViewModel(customTableRepo.GetCustomTable1Items(customTable.ClassName));
return View("~/Components/Widgets/CustomTableItems/_CustomTable1View.cshtml", ct1Model);
case "customtable.Table2":
// call your DTO for the customtable.Table2 object
var ct1Model = CustomTable2ViewModel.GetViewModel(customTableRepo.GetCustomTable2Items(customTable.ClassName));
return View("~/Components/Widgets/CustomTableItems/_CustomTable2View.cshtml", ct1Model);
}
}
}
While this is somewhat of a basic approach, I'm sure others could come up with a more complex/typed approach where you wouldn't have to add code everytime you added a custom table object in the UI.
Note: I typed this by hand in the editor so it may not be valid C#/API calls but you should get the idea.