This is a migrated thread and some comments may be shown as answers.

ComboBox Dynamic Load in Grid Item Template

9 Answers 278 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 19 Aug 2011, 05:35 AM
I am trying to get a RadComboBox to dynamically load the content when a user attempts to open the combo box.

The ComboBox is displayed in a RadGrid under the ItemTemplate (yes, not EditItemTemplate).

The problem is I get an error that says "The target {obj} for the callback could not be found or did not implement the ICallbackEventHandler.

What am I missing?   Here is my aspx:

<telerik:GridTemplateColumn HeaderText="Employee Type" DataType="System.String" >
    <ItemTemplate>
        <telerik:RadComboBox ID="uxEmployeeType" runat="server" Width="50px"
            DataTextField="Name" DataValueField="ID" EnableAutomaticLoadOnDemand="true"
            OnItemsRequested="uxEmployeeType_ItemsRequested" >
        </telerik:RadComboBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>


And here is my code.  

protected void uxEmployeeType_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
    RadComboBox uxEmployeeType = (RadComboBox)sender;
    uxEmployeeType.DataSource = _empTypes.EmployeeTypesMembers;
    uxEmployeeType.DataBind();
}

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Aug 2011, 08:24 AM
Hello Steven,

I suppose this issue arises because you are setting Automatic Load On Demand.Then you should set a data source id for the DataSourceID property of the RadComboBox. Since you are using  ItemsRequested event, then you shouldn't use Automatic Load On Demand, but supply the items to be loaded in the event handler function.For further information check the following demo and help article.
ComboBox / Combo in Grid
Automatic Load On Demand

Thanks,
Shinu
0
Steven
Top achievements
Rank 1
answered on 19 Aug 2011, 05:11 PM
I think I am confused, because from everything I have read (and tried) it should still work.

My goal is to keep EnableAutomaticLoadOnDemand = true and then do the data bind on the ItemDataBound event.  (Which I tried previously) and I get the same error.

protected void uxGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem )
    {
        // Get the row item
        GridDataItem rowItem = (GridDataItem)e.Item;
        // Bind the controls in each row
        RadComboBox uxEmployeeType = (RadComboBox)rowItem.FindControl("uxEmployeeType");
        uxEmployeeType.DataSource = _empTypes.EmployeeTypesMembers;
        uxEmployeeType.DataBind();
    }  
}

<telerik:GridTemplateColumn HeaderText="Employee Type" DataType="System.String" >
    <ItemTemplate>
        <telerik:RadComboBox ID="uxEmployeeType" runat="server" Width="50px"
            DataTextField="Name" DataValueField="ID" EnableAutomaticLoadOnDemand="true"  >
        </telerik:RadComboBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>


When the drop down is clicked I get the error.

If I turn off EnableAutomaticLoadOnDemand it works fine (but, of course, it does not pull the data at the time of the drop down click event).

I am starting to wonder if there is a problem using EnableAutomaticLoadOnDemand when inside of an item template.
0
Maria Ilieva
Telerik team
answered on 24 Aug 2011, 12:47 PM
Hello Steven,

Please note that you could not add control into RadGrid ItemTemplate on the ItemDataBound event. This should be definitely done in the ItemCreated event and also if the RadGrid is also dynamically created please ensure that you have create it correctly following the approach from this helps article.


Best wishes,
Maria Ilieva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Steven
Top achievements
Rank 1
answered on 24 Aug 2011, 03:08 PM
I don't think adding a control to a grid has anything to do with my question.   My question was about getting the AutomaticLoadOnDemand to work, not adding a control.

0
Maria Ilieva
Telerik team
answered on 29 Aug 2011, 01:34 PM
Hi Steven,

Note that if you need to use AutomaticLoadOnDemand you should not use the  ItemsRequested event for binding items to the RadComboBox. Actually the ItemsRequested event still fires with automatic Load On Demand. However this event handler could only be used for:
  • Add/Remove Items
  • Access/Change the ‘Show More Results’ message via the event arguments
  • Get/Set the EndOfItems event argument to explicitly stop subsequent ‘show more results/virtual scrolling’ requests


Kind regards,

Maria Ilieva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Praveen
Top achievements
Rank 1
answered on 09 Feb 2015, 03:13 PM
Getting below error while binding Combo Box on demand in RadGrid with BatchEdit Mode. Please help

 The target &#39;ctl11$RadGridSearchResult$ctl11_RadGridSearchResult_ctl00_Actplc$Actplc&#39; for the callback could not be found or did not implement ICallbackEventHandler. 

public class CreateRadComboTemplate : ITemplate
    {
        private string tempName;
        private int catId;
        public CreateRadComboTemplate(string templateName, int catId)
        {
            this.tempName = templateName;
            this.catId = catId;
        }

        public void InstantiateIn(System.Web.UI.Control container)
        {
            RadComboBox rcBox = new RadComboBox();
            rcBox.ID = this.tempName;
            rcBox.ItemsRequested += rcBox_ItemsRequested;
            rcBox.EnableAutomaticLoadOnDemand = true;
            container.Controls.Add(rcBox);
        }

        void rcBox_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            //throw new NotImplementedException();
        }
    }
0
Maria Ilieva
Telerik team
answered on 12 Feb 2015, 10:10 AM
Hi Praveen,

See the forum post below that should help in fixing the issue:

http://www.telerik.com/community/forums/aspnet-ajax/combobox/dynamically-created-combobox-and-load-on-demand-not-working.aspx

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Praveen
Top achievements
Rank 1
answered on 12 Feb 2015, 10:52 AM
Thanks..

Now I am getting another issue..

I am getting Javascript error for RadEditor in Radgrid with Batch edit mode only when cell contains tag like bold etc.
0
Konstantin Dikov
Telerik team
answered on 17 Feb 2015, 09:24 AM
Hello Praveen,

Having tags within the cell value is not supported scenario and it will break the Batch Editing functionality, because the BatchEditingManager expect a particular structure in the ItemTemplate. If you need to have complex ItemTemplate, you will have to handle the get/cell cell/editor values events and handle them manually. Detailed information and example is available in the following help article:

Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Steven
Top achievements
Rank 1
Maria Ilieva
Telerik team
Praveen
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or