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

Disable postback

7 Answers 481 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
DvdBrink
Top achievements
Rank 1
DvdBrink asked on 12 Aug 2010, 02:28 PM
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()
}


7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Aug 2010, 08:31 AM
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.
0
DvdBrink
Top achievements
Rank 1
answered on 13 Aug 2010, 08:57 AM
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.
0
Simon
Telerik team
answered on 16 Aug 2010, 03:03 PM
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
0
DvdBrink
Top achievements
Rank 1
answered on 16 Aug 2010, 03:08 PM
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).
0
Accepted
Simon
Telerik team
answered on 17 Aug 2010, 12:41 PM
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
0
DvdBrink
Top achievements
Rank 1
answered on 17 Aug 2010, 12:51 PM
Hello Simon,

Thank you very much for the solution. This works perfectly.
0
Jeanne Kornkven
Top achievements
Rank 1
answered on 24 Feb 2011, 05:46 PM
Simon,
     Thank you so much, this solves my problem too.
Jeanne Kornkven
Tags
ComboBox
Asked by
DvdBrink
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
DvdBrink
Top achievements
Rank 1
Simon
Telerik team
Jeanne Kornkven
Top achievements
Rank 1
Share this question
or