I found some code online that does most of what I want.
Im using something like this:
The 2 issues im having...
1) The delete button image sits to high and left on the tab. Is there a way to format where this sits within the createcloseimage() or attachcloseimage() functions?
2) The deletetab() function will remove the tab but not the window associated with is. The win variable get assigned the associated window but the removeWindow call doesn't seem to be working.
Im using something like this:
The 2 issues im having...
1) The delete button image sits to high and left on the tab. Is there a way to format where this sits within the createcloseimage() or attachcloseimage() functions?
2) The deletetab() function will remove the tab but not the window associated with is. The win variable get assigned the associated window but the removeWindow call doesn't seem to be working.
My call:
//create a new tab
var tab = new Telerik.Web.UI.RadTab();
//set the text of the tab
tab.set_text(itemText);
oWnd.correspondingTab = tab;
//add the tab to the tabstrip
tabStrip.get_tabs().add(tab);
AttachCloseImage(tab, "Images/close-md.png");
tabStrip.repaint();
tab.correspondingWnd = oWnd;
//tab.set_imageUrl(item.get_imageUrl());
tabStrip.commitChanges();
//Select this tab
tab.select();
function CreateCloseImage(closeImageUrl) {
var closeImage = document.createElement("img");
closeImage.src = closeImageUrl;
closeImage.border = "0";
//closeImage.alt = "";
return closeImage;
}
function AttachCloseImage(tab, closeImageUrl) {
var closeImage = CreateCloseImage(closeImageUrl);
closeImage.AssociatedTab = tab;
closeImage.onclick = function (e) {
if (!e) e = event;
if (!e.target) e = e.srcElement;
deleteTab(tab);
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
return false;
}
tab.get_innerWrapElement().appendChild(closeImage);
}
function deleteTab(tab) {
var win;
if (tab) {
win = tab.correspondingWnd;
tabStrip.trackChanges();
tabStrip.get_tabs().remove(tab);
tabStrip.commitChanges();
if (tabStrip._selectedIndex == -1) {
EnableDisableToolbarButtons();
}
}
//remove the corresponding window from the manager
manager.removeWindow(win);
}