开发者

onClientItemRequested doesn't select default item

I am trying to add default item 'All' to my RadComboBox. It is adding at the end and also it doesn't select this default item. What could be the problem? Are there any other ways to do it? Thank you..

function OnClientItemsRequested(sender, eventArgs) { 
      var combo = $find("<%= RadComboBox1.ClientID %>"); 
      var intextput = "All"; 
      var comboItem = new Telerik.Web.UI.RadComboBoxItem(); 
      comboItem.set_text(intextpu开发者_如何学Ct); 
      comboItem.set_value(""); 
      combo.trackChanges(); 

      combo.get_items().add(comboItem); 
      comboItem.select(); 
      combo.commitChanges(); 
      comboItem.scrollIntoView(); 
    } 

 <telerik:RadComboBox runat="server" ID="RadComboBox1"  
      EnableLoadOnDemand="true"  
      OnClientItemsRequested="OnClientItemsRequested"> 
      <WebServiceSettings Method="GetMyData" Path="http://localhost:1606/Service1.svc" /> 
    </telerik:RadComboBox>


I don't understand what's the get_items() function.

Shouldn't it be combo.Items.add(comboItem); ?


Use the insert(index, comboItem) method instead of add - it will give you the option to inject combo item as first. Something like the following:

 function OnClientItemsRequested(sender, eventArgs) { 
      var combo = $find("<%= RadComboBox1.ClientID %>"); 
      var intextput = "All"; 
      var comboItem = new Telerik.Web.UI.RadComboBoxItem(); 
      comboItem.set_text(intextput); 
      comboItem.set_value(""); 
      combo.trackChanges(); 

      combo.get_items().insert(0, comboItem); 
      comboItem.select(); //not sure whether you need this line of code
      combo.commitChanges(); 
      comboItem.scrollIntoView(); 
    } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜