How to update the EmptyMessage text using the *client-side* API

3 posts, 0 answers
  1. Ed
    Ed avatar
    124 posts
    Member since:
    Jan 2008

    Posted 23 Sep 2013 Link to this post

    Hi everyone,

    On the server, I can do this:

    RadListBox1.EmptyMessage = "No items available";

    How can I then alter this text later using the client-side API?  The equivalent function or property does not seem to exist.

    My project makes extensive use of AJAX and client-side updating, which can leave some of my list-boxes in an "indeterminate state" as they can only be adequately updated on the server (through data-binding).  Therefore I want to be able to clear these list-boxes on the client and display a temporary message that says "Click this button to refresh the list", where the button will then trigger a post-back and cause the current data to be bound to the list-box on the server.  Does that make sense?

    Ed Graham
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2013 Link to this post

    Hi Ed,

    You can use jQuery to achieve your requirement. Please have a look at the following code to clear the RadListBox items from client and update it with a new Empty Message.

    JavaScript:
    var radlistbox = $find('<%=RadListBox1.ClientID %>');
    radlistbox.get_items().clear();
    $telerik.$('.rlbEmptyMessage').text("New Empty Message");
    radlistbox._updateEmptyMessageVisibilty();

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ed
    Ed avatar
    124 posts
    Member since:
    Jan 2008

    Posted 24 Sep 2013 Link to this post

    Thanks, Shinu -- that works well in the case where there is only one list-box.  In my project I have several, so I needed to modify your code to this:

    var listBoxID = '<%=RadListBox1.ClientID %>';
    var radlistbox = $find(listBoxID);
    radlistbox.get_items().clear();
    // this works nicely when there is just one list-box
    //$telerik.$('.rlbEmptyMessage').text("New Empty Message");
    // *note*: the space before ".rlbEmptyMessage" is vital! (the whole string is a CSS selector, and they are very sensitive to syntax)
    $telerik.$('#' + listBoxID + ' .rlbEmptyMessage').text("New Empty Message");
    radlistbox._updateEmptyMessageVisibilty();
Back to Top