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

Current RadPageView JavaScript

5 Answers 247 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Kent
Top achievements
Rank 1
Kent asked on 07 Jan 2011, 03:12 AM
I have switched from a singe page display to a radtabstrip with dynamically created tabs linked to radpageviews.  Outside of all of this is a radtoolbar with controls that I need to control the currently opened radpageview.

Previously I had something like this in javascript:
function DefaultRadToolBarClick(sender, args)
            {
                var button = args.get_item().get_value();
                document.getElementById("txtAction").value = button;
                switch (button)
                {
                    case "tbrRunQuery" :
                        if ( window.frames(0).document.getElementById("loadingDiv")!= null)
                        {
                            window.frames[0].showLoading(true);
                        }
                        window.frames(0).document.getElementById("txtAction").innerText = button;
                        window.frames(0).document.forms(0).submit() ;
                        window.frames(0).document.getElementById("txtAction").innerText = "" ;
                        break ;
...

What would I replace the window.frames(0).document with to get the currently open radpageview?

Here is the HTML of the pane containing the tabs and pageviews:
<telerik:RadPane ID="DefaultRadPaneCont" runat="server">
<div class="content">
<telerik:RadTabStrip ID="DefaultRadTabStrip" align="left" Width="100%" runat="server" Skin="Office2007" MultiPageID="DefaultRadMultiPage">
<TabTemplate
<div class="textWrapper">
<%#DataBinder.Eval(Container, "Text")%> 
<img style="margin-left: 5px; margin-top: 5px" src="Images/delete.gif" alt="delete" onclick="deleteTab('<%# DataBinder.Eval(Container, "Text") %>')" /> 
</div>
</TabTemplate
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="DefaultRadMultiPage" runat="server">
</telerik:RadMultiPage>
 </div>
</telerik:RadPane>


5 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 07 Jan 2011, 03:28 PM
Hello Kent,

I don't see how this javascript even works, when you are using the incorrect array syntax. It should be [0] in square brackets, not (0) in parentheses.

I hope that helps.
0
Kent
Top achievements
Rank 1
answered on 08 Jan 2011, 01:24 AM
I dont see why you would think or hope that helps me?

Im looking for what I should be doing since I moved to a RadMultiPage inside a RadPane.  Not what may be wrong with what im trying not to use anymore.

I was thinking maybe it would be something like this:
function getCurrentPageView() {
var multiPage = $find("<%= DefaultRadMultiPage.ClientID %>");
var pageView = multiPage.get_selectedPageView();
if (!pageView) {
alert("You must select a tab.")
return false;
}
else {
return pageView;
}
}
  
function DefaultRadToolBarClick(sender, args)
{
var button = args.get_item().get_value();
var pageView = getCurrentPageView();
var doc = pageView.______________
doc.getElementById("txtAction").value = button;
switch (button)
{
case "tbrRunQuery" :
if ( doc.getElementById("loadingDiv")!= null)
{
window.frames[0].showLoading(true);
}
doc.getElementById("txtAction").innerText = button;
doc.forms(0).submit() ;
doc.getElementById("txtAction").innerText = "" ;
break ;

0
Simon
Telerik team
answered on 10 Jan 2011, 02:51 PM
Hi Kent,

Can you please shed more light on your goal? What is in the page view?

Kind regards,
Simon
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Kent
Top achievements
Rank 1
answered on 11 Jan 2011, 02:27 AM
The pageviews have contenturls assigned.  Its another one of my own pages, mostly reporting style (grid with filter up top).

I have that working now.  I do however have a couple of other problems.

The tabs are created and removed dynamically.  The problem I am having is when I create a tab, delete it, then create another tab the original pops back up.  I would guess that I need to check in my AddTab function, if any have been removed and remove them on the server side?

Heres the code:
Private Sub AddTab(ByVal tabName As String, ByVal url As String)
    Dim tab As RadTab = New RadTab
    tab.Text = Replace(tabName, "_", " ")
    radTabStrip.Tabs.Add(tab)
    Dim pageView As RadPageView = New RadPageView
    pageView.ID = tabName
    pageView.ContentUrl = url
    radMultiPage.PageViews.Add(pageView)
    radTabStrip.SelectedIndex = tab.Index
    radMultiPage.SelectedIndex = tab.Index
    radTabStrip.DataBind()
End Sub

<telerik:RadPane ID="RadPane1" runat="server">
<div class="content">
<telerik:RadTabStrip ID="RadTabStrip1" align="left" Width="100%" runat="server" Skin="Office2007" MultiPageID="DefaultRadMultiPage">
<TabTemplate
<div class="textWrapper">
<%#DataBinder.Eval(Container, "Text")%> 
<img style="margin-left: 5px; margin-top: 5px" src="Images/delete.gif" alt="delete" onclick="deleteTab('<%# DataBinder.Eval(Container, "Text") %>')" /> 
</div>
</TabTemplate
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server">
</telerik:RadMultiPage>
</div>
</telerik:RadPane>

function deleteTab(tabText) {
var tabStrip = $find("<%= DefaultRadTabStrip.ClientID %>");
var multiPage = $find("<%= DefaultRadMultiPage.ClientID %>"); 
var tab = tabStrip.findTabByText(tabText); 
var pageView = tab.get_pageView(); 
  
var tabToSelect = tab.get_nextTab(); 
if (!tabToSelect) 
tabToSelect = tab.get_previousTab(); 
  
tabStrip.get_tabs().remove(tab); 
multiPage.get_pageViews().remove(pageView); 
  
if (tabToSelect) 
tabToSelect.set_selected(true); 
}
0
Kent
Top achievements
Rank 1
answered on 12 Jan 2011, 02:50 AM
Got it.

function deleteTab(tabText) {
var tabStrip = $find("<%= DefaultRadTabStrip.ClientID %>");
tabStrip.trackChanges();
var multiPage = $find("<%= DefaultRadMultiPage.ClientID %>");
multiPage.trackChanges();
var tab = tabStrip.findTabByText(tabText); 
var pageView = tab.get_pageView(); 
  
var tabToSelect = tab.get_nextTab(); 
if (!tabToSelect) 
tabToSelect = tab.get_previousTab(); 
  
tabStrip.get_tabs().remove(tab); 
multiPage.get_pageViews().remove(pageView); 
  
if (tabToSelect)
    tabToSelect.set_selected(true);
tabStrip.commitChanges();
multiPage.commitChanges();
}
Tags
TabStrip
Asked by
Kent
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Kent
Top achievements
Rank 1
Simon
Telerik team
Share this question
or