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

Button in Combobox

1 Answer 275 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
amine
Top achievements
Rank 1
amine asked on 04 Apr 2012, 08:57 AM
Hi,
I have
 a combobox with a treeview ( checkbox activated). My problem is when a user selects multiple items he has to click somewhere on the page to exit the combobox, which is not very practical.
can I have two buttons "OK" "Cancel" in the combox? Something like that :
http://www.hostingpics.net/viewer.php?id=326557ButtoninCombo.png  

Thank you very much. 


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Apr 2012, 11:34 AM
Hi amine,

Try adding buttons inside the FooterTemplate of RadComboBox. Please take a look into the following sample.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" >
 <ItemTemplate>
  <telerik:RadTreeView runat="server" ID="RadTreeView1" CheckBoxes="true" >
   <Nodes>
    ..................
   </Nodes>
  </telerik:RadTreeView>
 </ItemTemplate>
 <FooterTemplate>
  <asp:Button ID="OK" runat="server" Text="OK" onclick="OK_Click" />
  <asp:Button ID="CANCEL" runat="server" Text="CANCEL" onclick="CANCEL_Click" />
 </FooterTemplate>
</telerik:RadComboBox>

C#:
protected void OK_Click(object sender, EventArgs e)
  {
    RadTreeView rtv = RadComboBox1.Items[0].FindControl("RadTreeView1") as RadTreeView;
    string s = "";
    for (int i = 0; i < rtv.CheckedNodes.Count; i++)
      {
        if(i==0)
          {
            s=s+rtv.CheckedNodes[0].Text ;
          }
        else
          {
            s = s + "," + rtv.CheckedNodes[i].Text;
          }
      }
    RadComboBox1.EmptyMessage = s;
  }
protected void CANCEL_Click(object sender, EventArgs e)
  {
    RadTreeView rtv = RadComboBox1.Items[0].FindControl("RadTreeView1") as RadTreeView;
    rtv.UncheckAllNodes();
    RadComboBox1.EmptyMessage = "";
  }

Hope this helps.

Thanks,
Princy.
Tags
ComboBox
Asked by
amine
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or