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

EmptyMessage not changing

3 Answers 129 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 23 Mar 2010, 01:30 PM
I've got a combobox in a toolbar and I'm trying to change the empty text in JS. The evidence suggests that the change is being applied but the empty message text that is displayed doesn't change.

Here's how the control is set up ...
<telerik:RadToolBar ID="RadToolBar1" runat="server" 
  Skin="Office2007" Style="width: 100%"
  <Items> 
    <telerik:RadToolBarButton Value="btnSkills"
      <ItemTemplate> 
        <telerik:RadComboBox ID="cboContactSkill" Runat="server" MaxHeight="200px"  
          EmptyMessage="Select skill(s)"  
          OnClientDropDownClosed="SkillsDropDownClosed" 
          Skin="WebBlue"
          <ItemTemplate> 
            <div id="div2"
              <telerik:RadTreeView ID="tvContactSkill" runat="server" 
                CheckBoxes="true" 
                DataFieldID="SkillId" 
                DataTextField="Name" 
                DataValueField="SkillId" 
                Skin="WebBlue"
              </telerik:RadTreeView> 
            </div> 
          </ItemTemplate> 
          <Items> 
            <telerik:RadComboBoxItem Text="" /> 
          </Items> 
        </telerik:RadComboBox> 
      </ItemTemplate> 
    </telerik:RadToolBarButton> 
  </Items> 
</telerik:RadToolBar> 

The JS looks like this ...
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
  <script type="text/javascript"
    function SkillsDropDownClosed(sender, e) { 
      var cbo = sender; 
      var tv = sender.get_items().getItem(0).findControl("tvContactSkill"); 
      cbo.trackChanges(); 
      var selectedNodes = tv.get_checkedNodes(); 
      if (selectedNodes == null || selectedNodes.length == 0) { 
        cbo.set_emptyMessage("None"); 
      } else if (selectedNodes.length == 1) { 
      cbo.set_emptyMessage(selectedNodes[0].get_text()); 
      } else { 
      cbo.set_emptyMessage("[multiple (" + selectedNodes.length + ")]"); 
      } 
      cbo.commitChanges(); 
      alert(cbo.get_emptyMessage()); 
      cbo.hideDropDown(); 
    } 
  </script> 
</telerik:RadScriptBlock> 

When called the alert message reads as I would expect, but the empty message displayed remains unchanged.

FWIW, I'm using Q3 2009.

--
Stuart


3 Answers, 1 is accepted

Sort by
0
Stuart Hemming
Top achievements
Rank 2
answered on 24 Mar 2010, 10:00 AM
FWIW, I changed the markup to remove the initial setting for EmptyMessage. Once I'd done this the message was changed on the first instance of the script being called but then didn't change on subsequent calls.

--
Stuart
0
Accepted
Simon
Telerik team
answered on 24 Mar 2010, 10:43 AM
Hi Stuart Hemming,

This happens because RadComboBox 'applies' the set empty message only when its text is an empty string (""). 

So if you call set_text("") before calling set_emptyMessage() you will achieve your goal.

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
Stuart Hemming
Top achievements
Rank 2
answered on 24 Mar 2010, 11:31 AM
Nice one, thanks Simon.

--
Stuart
Tags
ComboBox
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Stuart Hemming
Top achievements
Rank 2
Simon
Telerik team
Share this question
or