Hi,
I am trying to select tab from client-side javascript and select a corresponding view. Below is my code.. tab.get_pageView() returns null and I am not sure why. If I manually clicked on each tab corresponding pageView shows just fine, so my pageView exists.. What am I doing wrong? Is there better way of doing this?
Thanks!!
Kate
var tabStrip = $find("<%= rtsAllOtherTabs.ClientID %>");
var tab = tabStrip.findTabByValue("User");
if (!tab)
{
alert(
"There is no tab with text \"" + text + "\"");
return false;
}
tab.select();
//works til this line
var pv = tab.get_pageView(); // now pv is null
pv.set_selected(
true);
return false;
5 Answers, 1 is accepted
OnClientLoad
="selectTab"
of the tabstrip.
I also tried these code, but still getting null for the view. Thanks!
var pv = $find("<%=UserTab.PageViewID %>");
pv.set_selected(
true); //pv is null :( why??
Have you set MultiPageID property to the RadTabStrip? MultiPageID property must match the ID of the RadMultiPage control.
Best wishes,
Veronica Milcheva
the Telerik team
yes, MultiPageID is set properly, since if I manually click on the tab an appropriate view shows up. I am having problem only when I try to programmatically access the pageView for a tab using js :(
Thanks!
Kate
Please accept my appologies for misleading you. The valid MultiPageID is just necessary but not enough condition.
pv (corresponding pageView) is null because it is too early to call it at this event. The fact that the RadTabStrip is loaded doesn't necessarily means that the PageView is loaded too.
You can use the exactly same code at the pageLoad() event. This event is fired when the whole page is loaded.
function
pageLoad() {
var
tabStrip = $find(
"<%= SearchTab.ClientID %>"
);
var
tab = tabStrip.findTabByValue(
"0"
);
if
(!tab) {
alert(
"There is no tab with text \""
+ text +
"\""
);
return
false
;
}
tab.select();
alert(tab.get_text());
//works til this line
var
pv = tab.get_pageView();
// now pv is null
alert(pv.get_id());
pv.set_selected(
true
);
}
Find the full code in the attached .zip file.
Best wishes,
Veronica Milcheva
the Telerik team