Hi all,
I'm trying to use and customize my radCombox. I created a custom template class which implements ITemplate in order to create multi-columns (4 cols) combo. All have to be done dynamically in the code-behind... I use Internet Explorer 7, and the version of Telerik.Web.UI is 2008.3.1105.20.
First of all I initialize the templates in the Init() method of the page and set them to the combobox.
After I just bind a collection objects to the combobox.
The result is that the headerTemplate table is well sized, its width takes 100% of the container. In the ItemTemplate, the size of the table is not well sized because I suppose the table is contained in ul and li tag which generated by radcombobox.
How can I created a table dynamically and set its width to 100% in itemTemplate? Does anyone have an idea?
Find below a little portion of code that may help you...
protected void Page_Init(object sender, EventArgs e)
{
HeaderTemplate headertemplate = new HeaderTemplate();
ItemTemplate itemtemplate = new ItemTemplate();
this.cbxLocation.HeaderTemplate = headertemplate;
this.cbxLocation.ItemTemplate = itemtemplate;
}
public class HeaderTemplate : ITemplate
{
#region ITemplate Members
public void InstantiateIn(Control container)
{
HtmlTable table = new HtmlTable();
table.Width = Unit.Percentage(100).ToString();
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cell;
for (int i = 1; i <= 4; i++)
{
cell = new HtmlTableCell();
cell.Width = Unit.Percentage(100 / 4).ToString();
switch (i)
{
case 1: cell.InnerText = "Column 1";
break;
case 2: cell.InnerText = "Column 2";
break;
case 3: cell.InnerText = "Column 3";
break;
case 4: cell.InnerText = "Column 4";
break;
}
row.Controls.Add(cell);
}
table.Controls.Add(row);
container.Controls.Add(table);
}
#endregion
}
public class ItemTemplate : ITemplate
{
#region
ITemplate Members
public void InstantiateIn(Control container)
{
HtmlTable table = new HtmlTable();
table.Width =
Unit.Percentage(100).ToString();
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cell;
for (int i = 1; i <= 4; i++)
{
cell =
new HtmlTableCell();
cell.Width = Unit.Pixel(100 / 4).ToString();
switch (i)
{
case 1:
cell.InnerText = "Data 1";
break;
case 2:
cell.InnerText = "Data 2";
break;
case 3:
cell.InnerText = "Data 3";
break;
case 4:
cell.InnerText = "Data 4";
break;
}
row.Controls.Add(cell);
}
table.Controls.Add(row);
container.Controls.Add(table);
}
#endregion
}
Thanks for your help