Dextop C#模型中的计算场

Dextop C#模型中的计算场,c#,extjs4,C#,Extjs4,在Dextop C#模型中创建计算字段的最佳方法是什么,该模型执行以下操作: 基于FirstName和LastName字段为FullName字段创建值,类似于ExtJs中的以下内容: function fullName(v, record){ return record.name.last + ', ' + record.name.first; } Ext.define('Contact', { extend: 'Ext.data.Model', fields: [ {name: 'fulln

在Dextop C#模型中创建计算字段的最佳方法是什么,该模型执行以下操作:

基于FirstName和LastName字段为FullName字段创建值,类似于ExtJs中的以下内容:

function fullName(v, record){
return record.name.last + ', ' + record.name.first;
}

Ext.define('Contact', {
extend: 'Ext.data.Model',
fields: [
{name: 'fullname', convert: fullName},
{name: 'firstname', mapping: 'name.first'},
{name: 'lastname', mapping: 'name.last'}
]
});
当用户在表单上键入FirstName或LastName字段时,实时更新FullName字段

C#型号代码:

[DextopModel] 
[DextopGrid] 
[DextopForm] 
class MyModel 
{ 

[DextopModelId] 
[DextopGridColumn(width = 50, readOnly=true)]
public int Id { get; set; } 

[DextopFormField(anchor = "0", allowBlank = false, labelAlign = "top")]
[DextopGridColumn()]
public String FirstName { get; set; }

[DextopFormField(anchor = "0", allowBlank = false, labelAlign = "top")]
[DextopGridColumn()]
public String LastName { get; set; }

[DextopFormField(anchor="0", readOnly=true, labelAlign = "top")] 
[DextopGridColumn(flex=1)] 
public String FullName { get; set; }
}

答案很简单。Dextop支持服务器端的计算列。更改FullName属性,如下面的示例所示

[DextopFormField(anchor="0", readOnly=true, labelAlign = "top")] 
[DextopGridColumn(flex=1)]    
public String FullName { get { return String.Format("{0} {1}", FirstName, LastName); } }   

或者,您可以使用DextopModelField属性指定将在模型中生成的转换函数。

答案非常简单。Dextop支持服务器端的计算列。更改FullName属性,如下面的示例所示

[DextopFormField(anchor="0", readOnly=true, labelAlign = "top")] 
[DextopGridColumn(flex=1)]    
public String FullName { get { return String.Format("{0} {1}", FirstName, LastName); } }   
或者,您可以使用DextopModelField属性指定将在模型中生成的转换函数