I'm trying to make a dropdown use two values to display when choosing an item. In this scenario it is for a person's name. By default it is showing the Surname of the person. I would like to show the first name and surname if possible.
I've tried using ${data.PokerPlayer.Firstname} ${data.PokerPlayer.Surname} in the template field for the dropdown but it just doesn't seem to work.
'object' does not contain a definition for 'PokerPlayer' and no accessible extension method 'PokerPlayer' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
The line it refers to is in the razor file for the markup:
Based on the fact I'm fumbling along here, I have also tried using ${pokerreult.PokerPlayer.Forename} in the template field and whilst the application now compiles, I get a javascript error in the console in Chrome.
“data” is the data item. For example if a DataGrid is bound to IEnumerable of Order, “data” in templates will be of type Order and you can access properties using @data.OrderDate.
I can access the child properties in Radzen intellisense whether I use ${data.PokerPlayer} or ${pokerresult.PokerPlayer}. Its almost as if the PokerPlayer entity on pokerresult is null because if I set the template field to ${pokerresult.Position.ToString()} ${pokerresult.Points.ToString()} it works just fine and I see both properties in the Text for the dropdown.
It seems as though as soon as I try and use properties on the child entity (pokerresult.PokerPlayer) I get the errors.
So this drop down is in EditPage right? Please add PokerPlayer to $expand parameters of the data source method invoke that populates edited object on Page Load.
We found that actually the $expand parameter is not listed. Sorry for misleading you! It will be fixed in our upcoming release early next week. It will work out-of-the-box without needed to specify $expand parameter.
I just want to note though that if i use ${data.PropertyName} as per the documentation I get a design time error on the combo box. However, if I use the property that is assigned in the Load handler, in my case pokerresult it works just fine.
I cannot use ${data.Player.Forename} ${data.Player.Surname} in the template field because I get a design time error on screen and the application does not compile.
If I use ${finish.Player.Forename} ${finish.Player.Surname} this is what I get at runtime where all the players have the same name:
You should use ${data.Player.Forename} and ${data.Player.Surname}. The other will just use the same value for all items.
How is the Data of that DropDown set? For some reason Radzen thinks it is object. Show us a few screenshots from Radzen and the generated blazor code for that DropDown.
Can you also show us the generated code for that dropdown? Everything looks correct. We also need to see the declaration of the Player class. There is a high chance the Player class (which you are data-binding the DropDown to) doesn't have a Player property itself.
Player class which is inferred by the data connection looks like this:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace SuttonPokerResults.Models.PokerDb
{
[Table("Players", Schema = "dbo")]
public partial class Player
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int id
{
get;
set;
}
public ICollection<Finish> Finishes { get; set; }
public string Surname
{
get;
set;
}
public string Forename
{
get;
set;
}
public string Mobile
{
get;
set;
}
public string EmailAddress
{
get;
set;
}
public string Facebook
{
get;
set;
}
public string Twitter
{
get;
set;
}
public string HendonMob
{
get;
set;
}
public string PhotoLink
{
get;
set;
}
public string About
{
get;
set;
}
}
}