I couldn't manage to adapt the item display style of a SfComboBox. The combobox is using a DataSource. It seems that the given ItemTemplate only affects the option list but not the actual field showing the selected value.
the issue (the option "Deutschland" was selected before, but "de" is displayed instead. I want that the same string is used):
sample of my respective Xaml:
<border:SfBorder Style="{DynamicResource SfBorderStyle}" Margin="5" BorderColor="{StaticResource primaryTint}" CornerRadius="8">
<combobox:SfComboBox x:Name="selectCountry" Margin="20,5,0,0" Style="{StaticResource DefaultComboBoxStyle}"
Watermark="{x:Static p:Resources.SelectCountry}" SelectionChanged="countrySelectionChanged"
SelectedItem="{Binding SelectedCountry}" DataSource="{Binding Countries}">
<combobox:SfComboBox.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Name[de]}"/>
</DataTemplate>
</combobox:SfComboBox.ItemTemplate>
</combobox:SfComboBox>
</border:SfBorder>
the class of the data objects (note: this class gets generated. Thus I can't modifiy the class structure):
public class Country
{
[JsonProperty("code")]
public string Code {get; set;}
[JsonProperty("name")]
public Dictionary<string, string> Name {get; set;}
[JsonProperty("active")]
public bool Active {get; set;}
[JsonProperty("create_date")]
public DateTime? CreateDate {get; set;}
[JsonProperty("delete_date")]
public DateTime? DeleteDate {get; set;}
[JsonProperty("memo")]
public string? Memo {get; set;}
[JsonProperty("modify_date")]
public DateTime? ModifyDate {get; set;}
}
my goal is that the field of the combobox uses the same format as the option items do (eg. using the German name of the country). If possible I would like to accomplish this with plain XAML. I've already tried DisplayMemberPath on combobox:SfComboBox without success. Remember: a Country object's Name property is a Dictionary.
We have analyzed your query and currently we don’t have Dictionary support for DisplayMemberPath in SfComboBox and we have logged the feature request for this and you can track the status of the feature from below link
Feedback portal:
https://www.syncfusion.com/feedback/22399/provide-dictionary-datatype-support-for-displaymemberpath
Please cast your vote to make it count. We will prioritize the features every release based on the demands and we do not have an immediate plan to implement this feature since we have committed with already planned work. So, this feature will be available in any of our upcoming releases.
Related
I want to know how spring's multiple form:select works for following scenario:
I have a class UniSection has many students(Student class) and Students can selected zero or more selected course(SelectedCourse class) out of a list of courses(Course class)
public class UniSection{
private List<Student> students;
}
public class Student{
private List<SelectedCourse> selectedCourses;
}
public class SelectedCourses{
private String courseName;
}
In my jsp page, for a UniSection, then first select a student and then select some courses.
My command object is uniSection, how can I do a multiSelect for a selectedCourse?
I would like to do something like this
<form:select multiple="true" path="???">
<form:options items="courses" itemValue="???" itemLabel="???"/>
<form:select>
where courses is a list of all available courses. But what would come under path?
I dont think i can give path=students.selectedCourses as we need to assign course to particular student
I'm aware that i need a SelectedCoursePropertyEditor, but i don't know about the path expression.
In order to show a multiple-select with courses I think you need something like that:
<form:select multiple="true" path="students[i].selectedCourses">
<form:options items="${courses}" itemValue="courseName" itemLabel="courseName"/>
<form:select>
Where i, is a student from UniSection's list, and courses is a list containing all courses. When you submit this data, property Student.selectedCourses will be filled with selected rows.
I'm assuming this is a very very simple question. I'm wondering if I'm making a huge mistake because I supposed that this would be obvious but It's not working.
I'm trying to show a view which is using a viewmodel created specifically. Let's assume we are talking about:
public Order ActualOrder {get;set;}
public OtherType OtherVariable {get;set;}
public OtherType OtherVariable {get;set;}
Order is a complex type which holds some fields like:
[Required]
public int OrderId {get;set;}
[Required]
public string ClientName {get;set;}
[Required]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime DateAndTime {get;set}
I'm mapping in the view as:
#Html.EditorFor(p => p.Order.OrderId)
#Html.EditorFor(p => p.Order.ClientName)
#Html.EditorFor(p => p.Order.DateTime)
Everything works perfect in this line of communication. However, when I try to read the viewModel at the Action the variables are not set and, for example, the DateTimes are set to 01/01/0001 (which is wrong) but the client name is correctly set.
Viewmodel and Order have default constructor. Also, If I see the HTML generated the 'name' attribute seems to be correctly set.
I can't see the interactions that can be harming the mapping.
IMPORTANT
I've noticed that the problem comes from a jQuery DataPicker component. However, I'm using Firebug and I don't see 'name' or 'id' changing. Why the framework is not able to bind the model?
Should be pretty simple question here. I have
#Html.EditorFor(model=>model.Training)
I dont want to show some parts. Is there a way for me to exclude some from showing?
[ScaffoldColumn(false)]
public string SomeProperty {get; set;}
That should do the trick!
I am trying to strongly type a query for 3 ef objects using linq to sql. There are one-to-many relationships with product and category. My classes contain navigation properties and look like this.
public partial class Product
{
public int ID {get;set;}
public string Name {get;set;}
public virtual ICollection<Group> NpGroup {get;set;}
}
public partial class Category
{
public int ID {get;set;}
public string Name {get;set;}
public virtual ICollection<Group> NpGroup {get;set;}
}
public partial class Group
{
public int ID {get;set;}
public int ProductID {get;set;}
public int CategoryID {get;set;}
public virtual Product NpProduct {get;set;}
public virtual Category NpCategory {get;set;}
}
Trying to avoid the string based .Include(), how would I construct a query that returned a group equal to ProductID "1" but also included the names of the product and category?
Something like:
var context = ObjectContext.CurrentObjectContext;
var query = from c in context.Group
where c.ProductID == 1
//Include the names of the product and category of the group record (c.NpProduct.Name etc.)
select c;
I am probably missing the trees through the forest but I can not seem to get the syntax of ObjectContext.LoadProperty (if that is the right way to go).
Any thoughts? Thanks.
First of all, i doubt you are using both L2SQL and EF, so try not to confuse people.
Anyways, with EF - there is two ways to load the navigational properties:
1 - Eager Loading
q.Include("NavPropertyName")
2 - Explicit Load
*After* running your above query - use q.NavPropertyName.Load()
Difference is option 2) causes 2 queries, option 1 causes an inner join on the FK.
I can sympathise with your reluctance to use Include because of the 'magic strings' - i'm not sure why the EF team didn't make them strongly typed, however im sure there was a good reason.
More info on Load/Include here.
HTH
I think we all hate to use the typed string in the .include() statement.
I've started to use a enum to represent the table name, just to avoid spelling errors, etc.
for my database of about 70 tables it took me 10 min. to create the enum and my linq is now something like this:
var context = ObjectContext.CurrentObjectContext;
var query = from c in context.Group.Include(TableEnum.Category.ToString())
where c.ProductID == 1
select c;
Again, not perfect, but at least it's checked by the compiler
I use a ListView along with an ObjectDataSource tied to a business object. This object is defined as follows:
public class Employee
{
public int Id;
public string Name;
}
When I try setting the DataKeyNames property of the ListView to Id, ASP.net blows up and says:
DataBinding: 'Employee' does not contain a property with the name 'Id'.
However, when I change the object to that:
public class Employee
{
public int Id {get; set;}
public string Name;
}
It works!!!
I couldn't find any documentation about this behavior. Why is it not accepting a simple variable for DataKeyNames and instead it insists on a property?
There's not really a long explanation for this one, you've already found it. ASP.Net can bind to properties and not public variables. This is probably tied to the way the MSIL is generated. When compiled, a property is generated as a method (and binding allows you to bind to methods and properties) while public variables are not.
Unfortunately a quick search didn't uncover the reasoning beyond my own guess above, but here is MS saying "properties, expressions, methods" also: http://support.microsoft.com/kb/307860