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

Combobox with EnabledLoadOnDemand

8 Answers 80 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Grigory
Top achievements
Rank 1
Grigory asked on 30 May 2012, 08:28 AM
Hello!  If it's possible to disable user input in radcombobox with enabled load on demand set to true?  

I have a problem with user input in radcombobox, user could type everything in radcombobox and after submit when I'm trying to convert SelectedValue to integer there is an exception.  If it possible to select items or type only non-custom text?

8 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 30 May 2012, 10:54 AM
Hi Grigory,

Try the following JavaScript to disable user input in RadComboBox.

JS:
<script type="text/javascript">
  function pageLoad()
    {
        var combo =  $find("<%= RadComboBox1.ClientID%>");
        var input = combo.get_inputDomElement();
        input.disabled = "disabled";
    }
</script>

Hope this helps.

Regards,
Princy.
0
Grigory
Top achievements
Rank 1
answered on 30 May 2012, 01:34 PM
Thanks a lot , Princy
0
Grigory
Top achievements
Rank 1
answered on 30 May 2012, 02:28 PM
But if it possible to prevent text typing which don't exist in Item list?
0
Ivana
Telerik team
answered on 01 Jun 2012, 02:12 PM
Hi Grigory,

If you have load-on-demand enabled for RadComboBox in your scenario, there is no need to add a functionality that will prevent the typing in the input area if it does not match any item from the ItemsCollection of the control. When the user starts typing, no items will be fetched from the data source if there are no matches.
Take a look at the following online demo for more information on load-on-demand:
http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Grigory
Top achievements
Rank 1
answered on 01 Jun 2012, 02:19 PM
http://screencast.com/t/efCwZi4PXfC6

Can you see the screenshot? 

Yes there are empty list while I'am typing something wrong to the combobox input, but if I click outside the combobox the incorrect value will be selected. In my scenario on postback there are selected value parse to integer  and if there are no value which I typed there will be exception .. 
0
Shinu
Top achievements
Rank 2
answered on 05 Jun 2012, 11:29 AM
Hi Grigory,

As far as I know it is not possible to disable typing according to the RadComboBoxItem. One suggestion is that you can check in the SelectedIndexChanged event as follows.

C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        int i=0;
        foreach (RadComboBoxItem item in RadComboBox1.Items)
        {
            if (item.Text == RadComboBox1.Text)
            {
                i = 1;
            }
        }
        if (i == 0) //Typed text is not RadComboBoxItem
        {
            RadComboBox1.Text = "";
            //Your code
        }
        else  //Typed text is a RadComboBoxItem
        {
            //Your code
        }
    }

Hope this helps.

Thanks,
Shinu.
0
Ivana
Telerik team
answered on 06 Jun 2012, 06:33 AM
Hi Grigory,

If you are using server-side loading of items, you could an 'if'  check to your code which will make sure that the number of items being loaded is not zero; if it is zero, however, you should clear the text of the RadComboBox like this:
RadComboBox1.Text = "";

If you, on the other hand, are loading items from a Web server you could take advantage of the OnClientItemsRequested event where you could check the number of items being loaded from the service. Just like in the previous case, If this number is zero then you set the text of RadComboBox to empty string.

I hope this will help.

Greetings,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Grigory
Top achievements
Rank 1
answered on 06 Jun 2012, 06:37 AM
Thanks a lot to both of you!
Tags
ComboBox
Asked by
Grigory
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Grigory
Top achievements
Rank 1
Ivana
Telerik team
Shinu
Top achievements
Rank 2
Share this question
or