I have a PanelBar on my page that populated with items via the Client API. The functions that manipulate the PanelBar follow:
function BuildPanelBar(sender) {
var panelBar = sender;
var menuJson = JSON.parse('<%=Model.MenuItems %>');
panelBar.trackChanges();
var items = panelBar.get_items();
if (items.get_count() > 0) panelBar.get_items().clear();
for (var i = 0; i < menuJson.length; i++) {
var currentItem = menuJson[i];
var rootItem = new Telerik.Web.UI.RadPanelItem();
rootItem.set_text(currentItem.DisplayName);
if (currentItem.IsRootNode) {
addItemsToRoot(currentItem, rootItem);
}
panelBar.get_items().add(rootItem);
panelBar.commitChanges();
}
}
function addItemsToRoot(currentItem, rootItem) {
for (var i = 0; i < currentItem.ChildrenNodes.length; i++) {
var newCurrentItem = currentItem.ChildrenNodes[i];
var newItem = new Telerik.Web.UI.RadPanelItem();
newItem.set_text(newCurrentItem.DisplayName);
if (newCurrentItem.IsRootNode) {
addItemsToRoot(newCurrentItem, newItem);
}
rootItem.get_items().add(newItem);
}
}
I need the individual items to call a different JavaScript when they are clicked, and not postback to the server. I was hoping to do something like this:
newItem.set_onclick(<function goes here>);
but all I have found in the client api is the OnClientClick function that I declare at the PanelBar level. While each item that isn't a root node would call the same function, the values that the items would provide to the function would be different. Is there anyway to achieve what I am trying to do?
function BuildPanelBar(sender) {
var panelBar = sender;
var menuJson = JSON.parse('<%=Model.MenuItems %>');
panelBar.trackChanges();
var items = panelBar.get_items();
if (items.get_count() > 0) panelBar.get_items().clear();
for (var i = 0; i < menuJson.length; i++) {
var currentItem = menuJson[i];
var rootItem = new Telerik.Web.UI.RadPanelItem();
rootItem.set_text(currentItem.DisplayName);
if (currentItem.IsRootNode) {
addItemsToRoot(currentItem, rootItem);
}
panelBar.get_items().add(rootItem);
panelBar.commitChanges();
}
}
function addItemsToRoot(currentItem, rootItem) {
for (var i = 0; i < currentItem.ChildrenNodes.length; i++) {
var newCurrentItem = currentItem.ChildrenNodes[i];
var newItem = new Telerik.Web.UI.RadPanelItem();
newItem.set_text(newCurrentItem.DisplayName);
if (newCurrentItem.IsRootNode) {
addItemsToRoot(newCurrentItem, newItem);
}
rootItem.get_items().add(newItem);
}
}
I need the individual items to call a different JavaScript when they are clicked, and not postback to the server. I was hoping to do something like this:
newItem.set_onclick(<function goes here>);
but all I have found in the client api is the OnClientClick function that I declare at the PanelBar level. While each item that isn't a root node would call the same function, the values that the items would provide to the function would be different. Is there anyway to achieve what I am trying to do?