I downloaded a copy of Telerik's ASP.NET AJAX trial for the company I work for to see if we should buy it.
One of the 'nice to haves' we want is the autocomplete multicolumn combobox. I see the demo examples you give and it's for the radcombobox. That's hard to work with because I can't see how to add data from the database in codebehind. I tried google and I notice you have the radmulticolumncombox not available in the ajax trial. Why is that? How do I add it to the trial download because we need to see how it works for our clients ASAP.
Please respond.
5 Answers, 1 is accepted
Please take a look at this example - the columns in the first RadComboBox ( "Grid-like multi-column" ) are easily created in the ItemTemplate of the control. This is available in both the trial and dev versions of RadComboBox.
In this example you can see how to populate data from a database in RadComboBox. Please look at OnItemsRequested event handler of the first RadComboBox and the GetData method.
All the best,
Kalina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The definitions of the col1, col2 and col3 classes are:
.col1, .col2, .col3{ float: left; width: 110px; margin: 0; padding: 0 5px 0 0; line-height: 14px;}Finally, I noticed that you have similar post in our "windows forms" forum, where you are asking similar question. Can you please describe what you mean by "to access each RadCombobox column from codebehind" ?
Greetings,
Kalina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I have two comboboxes using your related combox example. The first one loads the second one via clientside just fine, however when I hit a search button based on the value in the second combobox, nothing is returned because the values in the second combobox gets emptied. What gives?
Here's the client-side code:
<tr>
<td class="detailLabelTop">Groups:</td><td class="detailFieldTop"><telerik:RadComboBox ID="rdComClientGroup"
OnClientSelectedIndexChanged="LoadRegions" runat="server" width="200px"></telerik:RadComboBox></td>
</tr>
<tr id="regionrow" runat ="server">
<td class="detailLabelTop">Regions:</td><td class="detailFieldTop"><telerik:RadComboBox ID="rdComRegion" OnItemsRequested="rdComRegion_ItemsRequested" OnClientItemsRequested="ItemsLoaded" runat="server" width="200px" ></telerik:RadComboBox></td>
</tr>
<script type="text/javascript">
//global variables for the countries and cities comboboxes
var regionsCombo;
var groupCombo;
function pageLoad() {
// initialize the global variables
// in this event all client objects
// are already created and initialized
groupCombo = $find("<%= rdComClientGroup.ClientID %>");
regionsCombo = $find("<%= rdComRegion.ClientID %>");
}
function LoadRegions(combo, eventArqs) {
var item = eventArqs.get_item();
regionsCombo.clearSelection();
regionsCombo.set_text("Loading...");
// if a group is selected
if (item.get_index() > 0) {
// this will fire the ItemsRequested event of the
// regions combobox passing the groupID as a parameter
regionsCombo.requestItems(item.get_value(), false);
regionsCombo.commitChanges
}
else {
// the -All- item was chosen
regionsCombo.set_text(" ");
regionsCombo.clearItems();
}
}
function ItemsLoaded(combo, eventArqs) {
if (combo.get_items().get_count() > 0) {
// pre-select the first item
combo.set_text(combo.get_items().getItem(0).get_text());
combo.get_items().getItem(0).highlight();
}
combo.showDropDown();
}
</script>
and here's the server-side code
public partial class Controls_FilterControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadClientGroups();
if (Request["client_group_code"] != null)
{
RadComboBoxItem _li_ClientGroup = rdComClientGroup.Items.FindItemByValue(Request["client_group_code"]);
if (_li_ClientGroup != null)
{
_li_ClientGroup.Selected = true;
LoadRegions(rdComClientGroup.SelectedValue);
if (Request["region_code"] != null)
{
RadComboBoxItem _li_Region = rdComRegion.Items.FindItemByValue(Request["region_code"]);
if (_li_Region != null)
{
_li_Region.Selected = true;
regionrow.Visible = true;
}
}
}
}
}
}
private void LoadClientGroups()
{
rdComClientGroup.Items.Clear();
rdComClientGroup.Items.Add(new RadComboBoxItem("All",""));
rdComRegion.Items.Clear();
DirectoryInfo imgDir = new DirectoryInfo(Server.MapPath("images/"));
IISearchClientGroup _search = new IISearchClientGroup();
_search.order_by = "client_group_name";
DataTable _dt = IIClientGroupHandler.Search(_search);
for (int i = 0; i < _dt.Rows.Count; i++)
{
RadComboBoxItem item;
item = new RadComboBoxItem(_dt.Rows[i]["client_group_name"].ToString(), _dt.Rows[i]["client_group_code"].ToString());
foreach (FileInfo file in imgDir.GetFiles("*.png"))
{
if (String.Compare(file.Name.Substring(0, 3), _dt.Rows[i]["client_group_name"].ToString().Substring(0, 3)) == 0)
{
item.ImageUrl = "~/images/" + file.Name;
}
}
rdComClientGroup.Items.Add(item);
}
rdComClientGroup.DataBind();
}
private void LoadRegions(string val)
{
//this.regionrow.Visible = true;
rdComRegion.Items.Clear();
rdComRegion.Items.Add(new RadComboBoxItem("All"));
DataTable _dt = IIRegionHandler.Search(val);
for (int i = 0; i < _dt.Rows.Count; i++)
{
rdComRegion.Items.Add(new RadComboBoxItem(_dt.Rows[i][2].ToString(), _dt.Rows[i][1].ToString()));
}
rdComRegion.DataBind();
}
protected void rdComRegion_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
LoadRegions(e.Text);
}
protected void rdComClientGroup_SelectedIndexChanged(object sender, EventArgs e)
{
if (rdComClientGroup.SelectedIndex > 0)
{
regionrow.Visible = true;
LoadRegions(rdComClientGroup.SelectedValue);
}
else
{
regionrow.Visible = false;
rdComRegion.Items.Clear();
}
regionrow.Visible = true;
}
protected void rdComClientGroup_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
LoadClientGroups();
}
protected void rdComRegion_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (rdComClientGroup.SelectedIndex > 0)
{
regionrow.Visible = true;
LoadRegions(rdComClientGroup.SelectedValue);
rdComRegion.SelectedValue = e.Value;
}
}
#region properties
public string ClientGroupCode
{
get
{
if (this.rdComClientGroup.SelectedIndex > 0)
{
return rdComClientGroup.SelectedValue;
}
return null;
}
}
public string RegionCode
{
get
{
if (this.rdComRegion.SelectedIndex > 0)
{
return rdComRegion.SelectedValue;
}
return null;
}
}
#endregion
}
The issue here is how to make the RadComboBox "remember" the entered text in such scenario.
The approach in your case is to set the AllowCustomText property of rdComRegion to true ( in your code there is manual load on demand although EnableLoadOnDemand is not set ).
As I understand you are implementing search functionality, so there is no need for users to type in RadComboBox input. That is why I provided additionally a javascript workaround, that makes the input readonly - handle the client-side Load event as shown below:
function onLoad(sender) { sender.get_inputDomElement().readOnly = "readonly";}I was unable to reproduce the issue with the code that you provided and I made a simple page (attached to this post) for you based on our online example.
Best wishes,
Kalina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.