Mar 18, 2019, 1:34 PM
Ext.Net 4.6 ComboBox Item List Title Template
Hello,
I had previously provided the Multicolumn feature for the ComboBox items when using Ext.Net 1.2. I have provided the title of the items by using the "Title" option.
I'm currently developing with Ext.Net 4.6 (MVC). I'm building my ComboBox on runtime. I use ItemTpl in the ListConfig for items.
My problem is that I can't find a "title" feature in which I can get multiple column support fixed on the combobox list. I need your urgent assistance in this matter.
I had previously provided the Multicolumn feature for the ComboBox items when using Ext.Net 1.2. I have provided the title of the items by using the "Title" option.
I'm currently developing with Ext.Net 4.6 (MVC). I'm building my ComboBox on runtime. I use ItemTpl in the ListConfig for items.
My problem is that I can't find a "title" feature in which I can get multiple column support fixed on the combobox list. I need your urgent assistance in this matter.
public Ext.Net.BaseControl PrepareComponent(ReportField reportField)
{
Connection cnn = new Connection();
var cmd3 = cnn.CreateCommand("SELECT BOUND_COLUMN_WIDTH,DESCRIPTION_COLUMN_WIDTH,EXTRA_COLUMNS_WIDTHS FROM TBLLIBCOMBO(NOLOCK) WHERE COMBO_NAME = @COMBO_NAME");
cnn.CreateParameter(cmd3, "@COMBO_NAME", DbType.AnsiString, reportField.COMBO_NAME);
var ww = cnn.Select(cmd3).Tables[0];
var boundWidth = DbUtil.GetInt(ww.Rows[0]["BOUND_COLUMN_WIDTH"]);
var descWidth = DbUtil.GetInt(ww.Rows[0]["DESCRIPTION_COLUMN_WIDTH"]);
var extraWidth = DbUtil.GetString(ww.Rows[0]["EXTRA_COLUMNS_WIDTHS"]);
var ExtraColumn = reportField.EXTRA_COLUMNS.Split(',');
var ExtraColumnWidth = extraWidth.Split(',');
Dictionary<string, string> ComboFields = new Dictionary<string, string>();
ComboFields.Add(reportField.BOUND_COLUMN, boundWidth.ToString());
if (reportField.BOUND_COLUMN != reportField.DESCRIPTION_COLUMN)
{
ComboFields.Add(reportField.DESCRIPTION_COLUMN, descWidth.ToString());
}
for (int i = 0; i < ExtraColumn.Length; i++)
{
if (reportField.BOUND_COLUMN != ExtraColumn[i] && reportField.DESCRIPTION_COLUMN != ExtraColumn[i] && !string.IsNullOrEmpty(ExtraColumn[i]))
{
string Width = "0";
if (ExtraColumnWidth.Length - 1 >= i)
Width = ExtraColumnWidth[i];
ComboFields.Add(ExtraColumn[i], Width);
}
}
var combo = new Ext.Net.ComboBox
{
ID = reportField.PARAMETER_NAME,
FieldLabel = Dictionary.Translate(reportField.CAPTION),
LabelSeparator = " ",
LabelWidth = 100,
Hidden = reportField.IS_HIDDEN,
Disabled = reportField.IS_DISABLED,
AnchorHorizontal = "60%",
QueryMode = Ext.Net.DataLoadMode.Remote,
QueryCaching = false,
ForceSelection = true,
FireSelectOnLoad = true,
TriggerAction = Ext.Net.TriggerAction.All,
PageSize = 10,
TypeAhead = true,
ListConfig = new BoundList()
{
LoadingText = "Aranıyor...",
ItemTpl = new Ext.Net.XTemplate()
{
Html = DynamicTemplateBuild(ComboFields)
}
}
};
}
internal static string DynamicTemplateBuild(Dictionary<string, string> Items)
{
StringBuilder Html = new StringBuilder();
if (Items.Count > 0)
{
Html.Append("<tpl for='.'>");
Html.Append("<div class='list-item' style='height:35px!important;height:21px;width:100%;'>");
}
foreach (var item in Items)
{
string Width = item.Value;
string Title = item.Key;
Html.Append(string.Format(@"
<div style='height:35px;float:left;width:{0};overflow:hidden;white-space:nowrap;' title='{{{1}}}'>{{{1}}}</div>",
string.IsNullOrEmpty(Width) || Width == "0" ? (100 / Items.Count).ToString() + "%" : Width,
Title
));
}
if (Items.Count > 0)
{
Html.Append("</div>");
Html.Append("</tpl>");
}
return Html.ToString();
}