Hi Telerik Support,
I have created a list of checkbox controls within Radmenu from code-behind with one root node and a list of menu-items directly under this root node with 3 columns - see attachment.
Test.aspx
Test.aspx.cs
My issue is:-
a) how can I use javascript to read all the text from checkbox (checked) and build a string store in hidden field so that I can access from code-behind.
b) When I check on the root node, all child-nodes will get checked. How to use javascript to read each checkbox in RadMenu?
c) I may add one hidden field together with checkbox in RadMenu then how to read this hidden field's value?
d) You have better way of presenting this design using other control?
I can use normal javascript to read them E.g. alert($get('RadMenu1_i0_i0_ck2').checked); But can I use the method provided by Telerik framework? I afraid this naming format may change in future by Telerik product upgrade. I have tried other methods provided in help file and from this forum with no help.
Anyone can help? Thanks in advanced.
PS
I have created a list of checkbox controls within Radmenu from code-behind with one root node and a list of menu-items directly under this root node with 3 columns - see attachment.
Test.aspx
<telerik:RadMenu runat="server" ID="RadMenu1" Skin="Vista" DataFieldID="ItemId" DataFieldParentID="ParentItemId" DataValueField="ItemId" DataTextField="Text" OnClientLoad="OnClientMenuLoaded"> <DefaultGroupSettings RepeatColumns="3" RepeatDirection="Vertical" /> </telerik:RadMenu>Test.aspx.cs
namespace WebApplication1{ public partial class ListViewIn_Menu : System.Web.UI.Page { protected override void OnInit(EventArgs e) { RadMenu1.ItemTemplate = new TextBoxTemplate(); base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { //Construct source list to bind to Menu List<MenuSelection> lstV = new List<MenuSelection>(); MenuSelection lstItm; for(int i = 1; i<= 50 ; i++) { if (lstV.Count == 0) { lstItm = new MenuSelection(); lstItm.ParentItemId = 0; lstItm.ItemId = lstV.Count + 1; lstItm.Checked = false; lstItm.Text = "MenuLevel1"; } else { lstItm = new MenuSelection(); lstItm.ItemId = lstV.Count + 1; lstItm.ParentItemId = 1; lstItm.Checked = GetSelectedList().Contains(lstItm.ItemId); lstItm.Text = "MenuLevel2_" + (lstV.Count + 1).ToString(); } lstV.Add(lstItm); } RadMenu1.DataSource = lstV; RadMenu1.DataBind(); } private List<int> GetSelectedList() { //Get the selected checkbox text from hidden field (where checkbox is checked) List<int> selList = new List<int>(); foreach (string itm in hidSelectedList.Value.Split(new char[] { '|' })) { if (!string.IsNullOrEmpty(itm)) { selList.Add(Convert.ToInt32(itm)); } } return selList; } } public class MenuSelection { public MenuSelection() { } public int ItemId { get; set; } public int ParentItemId { get; set; } public string Text { get; set; } public bool Checked { get; set; } } class TextBoxTemplate : ITemplate { public void InstantiateIn(Control container) { CheckBox cb = new CheckBox(); cb.DataBinding += new EventHandler(cb_DataBinding); container.Controls.Add(cb); } void cb_DataBinding(object sender, EventArgs e) { CheckBox target = (CheckBox)sender; RadMenuItem item = (RadMenuItem)target.BindingContainer; MenuSelection ds = (MenuSelection)item.DataItem; target.Checked = ds.Checked; target.Text = ds.Text; target.ID = "ck"; target.Attributes.Add("onclick", "OnMenuCheck_Click('" + ds.ItemId.ToString() + "')"); } }My issue is:-
a) how can I use javascript to read all the text from checkbox (checked) and build a string store in hidden field so that I can access from code-behind.
b) When I check on the root node, all child-nodes will get checked. How to use javascript to read each checkbox in RadMenu?
c) I may add one hidden field together with checkbox in RadMenu then how to read this hidden field's value?
d) You have better way of presenting this design using other control?
I can use normal javascript to read them E.g. alert($get('RadMenu1_i0_i0_ck2').checked); But can I use the method provided by Telerik framework? I afraid this naming format may change in future by Telerik product upgrade. I have tried other methods provided in help file and from this forum with no help.
Anyone can help? Thanks in advanced.
PS