Disable postback

8 posts, 1 answers
  1. DvdBrink
    DvdBrink avatar
    15 posts
    Member since:
    Jun 2012

    Posted 12 Aug 2010 Link to this post

    Hi,

    I have a RadComboBox with AutoPostBack set to true, but when i change te selection with javascript, it makes a post to the server, I'm looking for a way to (temporary) disable this behaviour. Is this possible?

    I'd rather not implement clientside combobox events, which would cancel the selectionchanged event.

    Below a bit of code.
    var field = $find(controlid);
    if (field) {
        field.disableEvents();
        var comboItem = new Telerik.Web.UI.RadComboBoxItem();
        comboItem.set_text("val");
        comboItem.set_value("val");
        field.set_enabled(true);
        field.trackChanges();
        field.get_items().clear();
        field.get_items().add(comboItem);
        comboItem.select();
        field.disable();
        field.commitChanges();
        field.enableEvents()
    }


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

    Posted 13 Aug 2010 Link to this post

    Hello Dick Van,


    One option is explicitly invoking the postback for the RadComboBox from the corresponding client events which you want to perform postback.
    Autopostback only when list item selected and not text entered


    Could you explain the scenario if this does not help?



    -Shinu.
  3. DvdBrink
    DvdBrink avatar
    15 posts
    Member since:
    Jun 2012

    Posted 13 Aug 2010 Link to this post

    Hello Shinu,

    Thank you for your reply.

    Sometimes, i change values on the client with Javascript. These values are send by the server, but because I'm not updating the whole page, but only a small piece with AJAX, the formfields aren't updated (performance reasons). The values which the form should get, are posted with this request.

    When my Javascript is called, it changes the values on the client (textboxes, raddatepicker, et cetera).
    When i call the "select" method, the combobox makes a postback to the server. However, I don't want the control to post the selectionchanged event to the server, because the server already knows which value is selected in the RadComboBox.

    For example, the RadDatePicker has the ability to (clientside) disable postbacks and enable them when ready:
    field.get_dateInput().set_autoPostBack(false);
    I'm looking for a same function with the RadComboBox.

    The thread you described gives me the same problem, because the OnClientSelectedIndexChanged event also gets called when the select method is called, so I don't know if I should cancel it.
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 16 Aug 2010 Link to this post

    Hello Dick Van den Brink,

    RadComboBox postbacks only if its AutoPostBack property is set to true, which I assume is true in your case. If you set the property to false you can disable the postbacks.

    I hope this helps.

    Sincerely yours,
    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. DvdBrink
    DvdBrink avatar
    15 posts
    Member since:
    Jun 2012

    Posted 16 Aug 2010 Link to this post

    Hi Simon,

    You're right about the Autopostback property, it is set to true, but I want it to postback when the user changes the selection.

    I don't want postbacks when I change the selection myself (with javascript).
  6. Answer
    Simon
    Admin
    Simon avatar
    2281 posts

    Posted 17 Aug 2010 Link to this post

    Hello Dick Van den Brink,

    Thank you for clarifying.

    You can do this with the following JS code:
    comboBox._postback = comboBox.postback;
    comboBox.postback = function () { };
    //item.select();
    comboBox.postback = comboBox._postback;

    The code simply substitutes the method that actually postbacks with an empty function during the change of selection and restores it afterwards. This effectively stops the postback when you change the selection manually.

    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
  7. DvdBrink
    DvdBrink avatar
    15 posts
    Member since:
    Jun 2012

    Posted 17 Aug 2010 Link to this post

    Hello Simon,

    Thank you very much for the solution. This works perfectly.
  8. Jeanne Kornkven
    Jeanne Kornkven avatar
    14 posts
    Member since:
    May 2008

    Posted 24 Feb 2011 Link to this post

    Simon,
         Thank you so much, this solves my problem too.
    Jeanne Kornkven
Back to Top