Hello
I will narrow down my requirement a little, adding a sample
I have following control
public class CompanyPickerControl : FieldContainer, INamingContainer
{
public string CopyFromButtonText
{
get { return _btnCopyFrom.Text; }
set { _btnCopyFrom.Text = value; }
}
public bool CopyFromButtonHidden
{
get { return _btnCopyFrom.Hidden; }
set { _btnCopyFrom.Hidden = value; }
}
public string OpeningHoursText
{
get { return _btnOpeningHours.Text; }
set { _btnOpeningHours.Text = value; }
}
public bool DispatchVisible
{
get { return _ddlDispatch.Visible; }
set
{
_addDispatch.Visible = value;
_ddlDispatch.Visible = value;
}
}
public string CopyFromInstance { get; set; }
private Button _btnOpeningHours = new Button
{
Text = "Opening Hours",
Icon = Icon.Time,
ItemID = "btnOpeningHours",
Cls = "greyButton"
};
private ComboBox _ddlCompany = new ComboBox
{
//Width = 320,
Cls = "companyPickerCompanyDropdown",
EmptyText = "-- Select Company --",
ValueField = "Id",
DisplayField = "DisplayString",
ItemID = "ddlCompany",
TypeAhead = false,
TriggerAction = TriggerAction.Query,
MinChars = 0,
ForceSelection = true,
BlankText = "Company is required",
Store =
{
new Store
{
WarningOnDirty = false,
AutoLoad = false,
Proxy =
{
new PageProxy ()
{
DirectFn ="Ext.net.DirectMethods.FindCompanyAccordingPrefix"
// Json = true,
// Url = URLResolver.RootDirectory.GetAbsoluteUrl("~/ExtDataService.asmx/FindCompanyAccordingPrefix"),
//Reader =
//{
// new JsonReader
// {
// Root = "d",
// }
//},
}
},
Model =
{
new Model
{
IDProperty = "Id",
Fields =
{
new ModelField("Id",ModelFieldType.Int),
new ModelField("CityId",ModelFieldType.Int)
{
AllowNull = true
},
new ModelField("CityName"),
new ModelField("DisplayString"),
new ModelField("LoadingDock",ModelFieldType.Boolean)
{
AllowNull = true
},
new ModelField("IsPort",ModelFieldType.Boolean)
{
AllowNull = true
},
new ModelField("Name"),
new ModelField("CountryId",ModelFieldType.Int)
{
AllowNull = true
},
new ModelField("StateId",ModelFieldType.Int),
new ModelField("AddressDetails"),
new ModelField("ZipCode"),
new ModelField("IconCls")
}
}
}
}
}
};
private Button _btnCopyFrom = new Button
{
Text = "Copy",
Icon = Icon.PageCopy,
ItemID = "btnCopyFrom",
Cls = "greyButton",
Hidden = true
};
private ComboBox _ddlDispatch = new ComboBox
{
//Width = 320,
EmptyText = "-- Select Dispatch --",
Cls = "companyPickerPersonDropdown",
ItemID = "ddlDispatch",
ValueField = "Id",
Visible = false,
Flex = 1,
TriggerAction = TriggerAction.All,
DisplayField = "Location",
TypeAhead = false,
BlankText = "Dispatch is required",
MarginSpec = "0 0 10 0",
QueryMode = DataLoadMode.Remote,
ForceSelection = true,
Store =
{
new Store
{
WarningOnDirty = false,
AutoLoad = false,
Model =
{
new Model
{
IDProperty = "Id",
Fields =
{
new ModelField("Id", ModelFieldType.Int),
new ModelField("Location"),
new ModelField("DispatchId",ModelFieldType.Int),
}
}
}
}
}
};
private Button _addDispatch = new Button
{
Text = "Add",
Visible = false,
Icon = Icon.Add,
Width = 50,
ItemID = "addDispatch",
MarginSpec = "0 5 10 0"
};
private ComboBox _ddlPerson = new ComboBox
{
//Width = 320,
EmptyText = "-- Select Employee --",
Cls = "companyPickerPersonDropdown",
ItemID = "ddlPerson",
ValueField = "Id",
TriggerAction = TriggerAction.All,
DisplayField = "DisplayString",
TypeAhead = false,
BlankText = "Contact is required",
QueryMode = DataLoadMode.Remote,
ForceSelection = true,
Store =
{
new Store
{
WarningOnDirty = false,
AutoLoad = false,
Model =
{
new Model
{
IDProperty = "Id",
Fields =
{
new ModelField("Id", ModelFieldType.Int),
new ModelField("DisplayString"),
new ModelField("AddressDetails"),
new ModelField("Email"),
new ModelField("FirstName"),
new ModelField("LastName"),
new ModelField("IconCls")
}
}
}
}
}
};
private Label _txtCompanyNote = new Label
{
// Width = 320,
Text = "Im not able to copy this text using mouse",
Flex = 1,
Disabled = true,
Cls = "companyPickerCompanyNote",
ItemID = "txtCompanyNote",
AutoScroll = true,
};
private Panel _txtPersonNote = new Panel
{
Flex = 1,
Html = "Im not able to copy this text using mouse",
MinHeight = 10,
Disabled = true,
Cls = "companyPickerPersonNote",
ItemID = "txtPersonNote",
AutoScroll = true
};
public CompanyPickerControl()
{
Height = 230;
}
//public void SetCompanyAndPerson(CompanyPickerCompanyDTO company,CompanyPickerPersonDTOLoad person)
//{
// //ActiveCompany = company;
// //string serializedCompany = JsonConvert.SerializeObject(company);
// //string serializedPerson = JsonConvert.SerializeObject(person);
// this.Call("setCompanyAndPerson",company,person);
//}
public bool DisplayNameOnly { get; set; }
protected override void OnInit(EventArgs e)
{
//((AjaxProxy)_ddlCompany.Store[0].Proxy[0]).ActionMethods.Read = HttpMethod.POST;
//((AjaxProxy)_ddlPerson.Store[0].Proxy[0]).ActionMethods.Read = HttpMethod.POST;
if (string.IsNullOrEmpty(ID) == false)
{
_ddlCompany.ID = ID + "_ddlCompany";
_ddlPerson.ID = ID + "_ddlPerson";
}
if (_ddlCompany.ListConfig == null)
_ddlCompany.ListConfig = new BoundList();
if (DisplayNameOnly)
{
_ddlCompany.DisplayField = "Name";
_ddlCompany.ListConfig.ItemTpl = new XTemplate
{
Html = @"<tpl for="".""><div class=""icon-combo-item"">{Name}</div></tpl>"
};
}
else
{
_ddlCompany.ListConfig.ItemTpl = new XTemplate
{
Html = @"<tpl for="".""><div class=""icon-combo-item {IconCls}"">{DisplayString}</div></tpl>"
};
}
if (_ddlPerson.ListConfig == null)
_ddlPerson.ListConfig = new BoundList();
_ddlPerson.ListConfig.ItemTpl = new XTemplate
{
Html = @"<tpl for="".""><div class=""x-combo-list-item icon-combo-item {IconCls}"">{DisplayString}</div></tpl>"
};
Frame = true;
LayoutConfig.Add(new VBoxLayoutConfig
{
Align = VBoxAlign.Stretch
});
var iconContainer = new Container
{
ItemID = "iconContainer",
Width = 30,
Layout = "vbox",
MarginSpec = "0 7 0 0",
};
var buttonContainer = new FieldContainer
{
Height = 30,
LayoutConfig =
{
new HBoxLayoutConfig
{
Align = HBoxAlign.Middle
}
},
MarginSpec = "0 0 5 0",
Cls = "companyPickerCompanyButtonPanel",
Items =
{
new Button
{
MarginSpec="0 5 0 0",
Text = "Search",
Icon = Icon.Magnifier,
ItemID = "btnSearch",
Cls="greyButton"
},
_btnOpeningHours,
_btnCopyFrom
}
};
Items.AddRange(new List<AbstractComponent>{
_ddlCompany,
new Container
{
Flex=1,
LayoutConfig = {
new HBoxLayoutConfig
{
Align = HBoxAlign.Stretch
}
},
Items = {
_txtCompanyNote,
iconContainer
}
},
//new FieldContainer
// {
// Flex = 1,
// Layout = "Fit",
// Items =
// {
// _txtCompanyNote
// }
// },
buttonContainer,
new Container
{
Layout = "hbox",
Items =
{
_ddlDispatch,
_addDispatch
}
},
_ddlPerson,
_txtPersonNote,
//new FieldContainer
// {
// Layout = "Fit",
// Flex = 1,
// Items =
// {
// _txtPersonNote
// }
// }
new FieldContainer
{
Height = 30,
LayoutConfig =
{
new HBoxLayoutConfig
{
Align = HBoxAlign.Middle
}
},
Items =
{
new Button
{
Text = "Add Person",
Icon = Icon.UserAdd,
ItemID = "btnAddPerson",
Cls="greyButton"
},
new Container
{
Flex=1
},
new Button
{
Text = "Clear",
Icon = Icon.Cross,
ItemID = "btnClear",
Cls="greyButton"
}
}
}
});
base.OnInit(e);
}
public bool AllowBlankCompany
{
get
{
return _ddlCompany.AllowBlank;
}
set
{
_ddlCompany.AllowBlank = value;
}
}
public bool AllowBlank
{
get
{
return _ddlPerson.AllowBlank;
}
set
{
_ddlPerson.AllowBlank = value;
_ddlCompany.AllowBlank = value;
}
}
public bool AllowBlankPerson
{
get
{
return _ddlPerson.AllowBlank;
}
set
{
_ddlPerson.AllowBlank = value;
}
}
}
and following "page"
<ext:Container Reference="rootContainer" >
<Items>
<ext:Panel runat="server" Html="I can copy this text"></ext:Panel>
<ext:Label runat="server" Text="I can copy this text"></ext:Label>
<wa:CompanyPickerControl runat="server"/>
</Items>
</ext:Container>
Now what I dont undertand is
- why I can copy text from first two controls ( label +panel) on page
- why I cannot copy text fromlabel and panel inside CompanyPickerControl