BDCEntityPickerID = new Microsoft.SharePoint.Portal.WebControls.ItemPicker();
BDCEntityPickerID.ID = "BDCEntityPickerID";
BDCEntityPickerID.AllowTypeIn = true;
BDCEntityPickerID.AllowEmpty = false;
BDCEntityPickerID.AutoPostBack = true;
BDCEntityPickerID.MultiSelect = false;
BDCEntityPickerID.Load += new EventHandler(BDCEntityPickerID_Load);
Controls.Add(BDCEntityPickerID);
protected void BDCEntityPickerID_Load(object sender, EventArgs e)
{
// Set extended data
BDCEntityPickerID.ExtendedData = GetExtendedData("MyInstance", "Tablename", "ColumnName_picker");
// Set other properties
}
protected Portal.ItemPickerExtendedData GetExtendedData(string lobInstanceName, string entityName, string titleFieldName)
{
// Create a new ExtendedData object
Portal.ItemPickerExtendedData data = new Portal.ItemPickerExtendedData();
// Get the LOB Instance
LobSystemInstance lob = ApplicationRegistry.GetLobSystemInstanceByName(lobInstanceName);
data.SystemInstanceId = lob.Id;
// Get the entity
Entity entity = lob.GetEntities()[entityName];
data.EntityId = entity.Id;
// Set the primary column id (the id of the "Title" field)
FieldCollection fields = entity.GetSpecificFinderView().Fields;
List
foreach (Field field in fields)
{
if (string.Equals(field.Name, titleFieldName, StringComparison.OrdinalIgnoreCase))
{
data.PrimaryColumnId = field.TypeDescriptor.Id;
}
else
{
secondaryColumnIds.Add(field.TypeDescriptor.Id);
}
}
data.SecondaryColumnsIds = secondaryColumnIds.ToArray();
return data;
}
No comments:
Post a Comment