ComboBox Dynamic Load in Grid Item Template

10 posts, 0 answers
  1. Steven
    Steven avatar
    84 posts
    Member since:
    Oct 2010

    Posted 19 Aug 2011 Link to this post

    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();
    }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Aug 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steven
    Steven avatar
    84 posts
    Member since:
    Oct 2010

    Posted 19 Aug 2011 Link to this post

    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.
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 24 Aug 2011 Link to this post

    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 >>

  6. Steven
    Steven avatar
    84 posts
    Member since:
    Oct 2010

    Posted 24 Aug 2011 Link to this post

    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.

  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 29 Aug 2011 Link to this post

    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 >>

  8. Praveen
    Praveen avatar
    34 posts
    Member since:
    Apr 2009

    Posted 09 Feb 2015 Link to this post

    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();
            }
        }
  9. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 12 Feb 2015 Link to this post

    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.

     
  10. Praveen
    Praveen avatar
    34 posts
    Member since:
    Apr 2009

    Posted 12 Feb 2015 in reply to Maria Ilieva Link to this post

    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.
  11. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 17 Feb 2015 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017