RadComboBoxItemsRequestedEventArgs.EndOfItems not working

7 posts, 1 answers
  1. iTools
    iTools avatar
    28 posts
    Member since:
    Jun 2007

    Posted 14 Jun 2010 Link to this post

    I have a RadCombo using LoadOnDemand and ShowMoreResultsBox because my RadComboBox needs to support a large data source.
    I have tried, without success, to disable the MoreResultsBox when the end of the the data source is reached.

    Here is what I'm doing:
    Private WithEvents ctlRadCombo As New RadComboBox() With { 
            .ID = "ctlRadCombo"
            .EmptyMessage = "Enter some text"
            .ShowMoreResultsBox = True
            .EnableViewState = False
            .EnableLoadOnDemand = True
            .AppendDataBoundItems = True
            .NoWrap = True
            .ItemRequestTimeout = 1000, 
            .Width = 350, 
            .MaxHeight = 400 
        } 
     
        Private Sub Page_Init(ByVal sender As ObjectByVal e As EventArgs) Handles Me.Init 
            pnlContents.Controls.Add(ctlRadCombo) 
            AddHandler ctlRadCombo.ItemsRequested, AddressOf ctlRadCombo_ItemsRequested 
        End Sub 
     
        Private Sub ctlRadCombo_ItemsRequested(ByVal sender As ObjectByVal e As RadComboBoxItemsRequestedEventArgs) 
            Dim theCombo As RadComboBox = DirectCast(sender, RadComboBox) 
            Dim maxItems As Integer 
     
            Dim fromRow As Integer = e.NumberOfItems + 1 
            Dim toRow As Integer = fromRow + 9 
            Dim items As IDictionary(Of IntegerString) = GetItemsByText(e.Text, fromRow, toRow, maxItems) 
            Dim data As IDictionary(Of IntegerString) = items 
            theCombo.DataTextField = "Value" 
            theCombo.DataValueField = "Key" 
            theCombo.DataSource = data 
            theCombo.DataBind() 
     
            e.EndOfItems = maxItems <= toRow 
            theCombo.ShowMoreResultsBox = Not e.EndOfItems 
        End Sub 

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 15 Jun 2010 Link to this post

    Hello jan fischer,

    During Items requests only Item data is sent back to the client, i.e. the control itself is not updated even if some of its properties are altered.

    However, you can disable the functionality of the 'Show More Results' box and stop further Items requests if you set the e.EndOfItems property to true in the ItemsRequested event handler.

    Another approach would be to handle the client-side ItemsRequested event and in the event handler hide the box element by setting to it a display: none style:

    function onItemsRequested(sender, eventArgs) {
        sender.get_moreResultsBoxMessageElement().style.display = "none";
    }

    Greetings,
    Simon
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. iTools
    iTools avatar
    28 posts
    Member since:
    Jun 2007

    Posted 15 Jun 2010 Link to this post

    Hello Simon,

    I have tried what you have suggested in regards to "you can disable the functionality of the 'Show More Results' box and stop further Items requests if you set the e.EndOfItems property to true in the ItemsRequested event handler", but it does not work...

    Here is an example:

    <asp:ScriptManager ID="ctlScriptManager" runat="server" /> 
    <telerik:RadComboBox id="ctlRadCombo" runat="server" 
        ShowMoreResultsBox="True" 
        EnableLoadOnDemand="True" /> 

    Private Sub ctlRadCombo_ItemsRequested(ByVal sender As ObjectByVal e As RadComboBoxItemsRequestedEventArgs) Handles ctlRadCombo.ItemsRequested 
        e.EndOfItems = True 
    End Sub 

    When running the code as shown above, the MoreResultsBox is not disabled on ItemRequest events.
    My version of Telerik.Web.UI is 2008.3.1125.20.

    I have tried the same sample with the latest version of Telerik.Web.UI, and it works. But, style changes between these versions makes it too difficult to upgrade at this stage.

    Please advise on an appropriate workaround.

    Thanks.
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 16 Jun 2010 Link to this post

    Hi jan fischer,

    Perhaps this is a bug in the version you are using.

    You can try resolving it by handling the ItemsRequesting event in this way:
    function onItemsRequesting(sender, eventArgs) {
        eventArgs.set_cancel(sender.get_endOfItems());
    }

    and adding the following script to the page as well:
    var p = Telerik.Web.UI.RadComboBox.prototype;
    var requestItems = p.requestItems;
    p.requestItems = function(text, appendItems) {
        if (!appendItems)
            this.set_endOfItems(false);
        requestItems.apply(this, arguments);
    }

    Regards,
    Simon
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. iTools
    iTools avatar
    28 posts
    Member since:
    Jun 2007

    Posted 20 Jun 2010 Link to this post

    Hello Simon,

    I have tried the javascript you have provided and I am experiencing the same behaviour as before.

    I don't see how the javascript you provided would circumvent the problem since Snippet this.set_endOfItems(false); is not called?
    Also, sender.get_endOfItems() in either the Snippet OnClientItemsRequesting or Snippet OnClientItemsRequested client-side event handlers always return false even if e.EndOfItems is set to true in the server-side ItemsRequested event handler.
  6. Answer
    Simon
    Admin
    Simon avatar
    2281 posts

    Posted 23 Jun 2010 Link to this post

    Hello jan fischer,

    I just verified the solution again with this setup:
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <telerik:RadComboBox ID="RadComboBox1" runat="server" ShowMoreResultsBox="True" EnableLoadOnDemand="True"
                OnClientItemsRequesting="onItemsRequesting">
            </telerik:RadComboBox>
        </div>
        </form>
     
        <script type="text/javascript">
            function onItemsRequesting(sender, eventArgs) {
                eventArgs.set_cancel(sender.get_endOfItems());
            }
     
            var p = Telerik.Web.UI.RadComboBox.prototype;
            var requestItems = p.requestItems;
     
            p.requestItems = function(text, appendItems) {
                if (!appendItems)
                    this.set_endOfItems(false);
                     
                requestItems.apply(this, arguments);
     
            }
        </script>
     
    </body>

    and this code in the ItemsRequested event handler:
    RadComboBox1.Items.Add(New Telerik.Web.UI.RadComboBoxItem("item " + e.Text))
     
    e.EndOfItems = True

    and it worked fine. In other words, if I type something, then the corresponding Item is properly loaded on demand. If I click on the 'show more results' box, nothing happens.

    Please let me know if I am missing something.

    Regards,
    Simon
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. iTools
    iTools avatar
    28 posts
    Member since:
    Jun 2007

    Posted 23 Jun 2010 Link to this post

    Hi Simon,
    It works exactly as I expect it to now!
    Thanks!!

Back to Top