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

Deleting dynamic pageviews using Javascript

6 Answers 123 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Babu Puchakayala
Top achievements
Rank 1
Babu Puchakayala asked on 27 May 2010, 04:06 AM
Hi,

I created dynamic tab creation application using telerik radstrip. I can delete the tabs that are creating dynamically using crossbar option. When i am deleting the tabs its just deleting the tabs but not pageview corresponding to the tab. I have tried to delete the pageviews but i am getting error like "Microsoft JScript runtime error: Object doesn't support this property or method" and pointing to

multiPage.get_pageViews().remove(pageView); code. Can anyone help me how to delete pageviews.

Thanks in advance.

Javascript code.

   
<script type="text/javascript"
        /* <![CDATA[ */
        function deleteTab(tabText) {
            var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
            
            var multiPage = $find("<%= RadMultiPage1.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);
        }
        /* ]]> */ 
    </script>  

6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Jun 2010, 10:54 AM
Hi Babu,

You code is correct. I tested it and everything worked as expected. Are there any other details around your case that we should be aware of?

Best wishes,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Babu Puchakayala
Top achievements
Rank 1
answered on 01 Jun 2010, 03:30 PM
Hi Peter,

Here is my C# Code. Let me know if you need anything.
protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!Page.IsPostBack) 
        { 
 
            RadTab tab = new RadTab(); 
            tab.Text = "Tab"
            RadTabStrip1.Tabs.Add(tab); 
 
            RadPageView pageView = new RadPageView(); 
            RadMultiPage1.PageViews.Add(pageView); 
            BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count); 
            RadTabStrip1.SelectedIndex = 0
 
            RadTabStrip1.DataBind(); 
 
        } 
    } 
 
    private void BuildPageViewContents(RadPageView pageView, int index) 
    { 
        pageView.ID = "Page" + index.ToString(); 
        pageView.Controls.Add(new LiteralControl(" <B>Page</B>" + (index).ToString())); 
    } 
 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
 
        RadTab tab = new RadTab(); 
        tab.Text = string.Format("Page{0}", RadTabStrip1.Tabs.Count + 1); 
        //RadTabStrip1.ID = "Tab" + RadTabStrip1.Tabs.Count;  
        RadTabStrip1.Tabs.Add(tab); 
 
        RadPageView pageView = new RadPageView(); 
        pageView.ID = "Page" + pageView.Index.ToString(); 
        //RadMultiPage1.ID = "page" + pageView.Index.ToString(); 
        RadMultiPage1.PageViews.Add(pageView); 
 
        BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count); 
        RadTabStrip1RadTabStrip1.SelectedIndex = RadTabStrip1.SelectedIndex + 1; 
        RadMultiPage1.SelectedIndex = RadTabStrip1.SelectedIndex; 
        RadTabStrip1.DataBind(); 
 
    } 
 
    protected void RadMultiPage1_PageViewItemCreated1(RadPageView view, int viewIndex) 
    { 
        BuildPageViewContents(view, viewIndex + 1); 
    } 
 

0
Peter
Telerik team
answered on 04 Jun 2010, 01:17 PM
Hello Babu,

The problem is with this code actually - var pageView = tab.get_pageView(); . Here pageView is null since there is no MultiPageID associated with RadTabStrip. To avoid the problem, please try the following modification to your code:

if (!Page.IsPostBack)
       {
           RadTab tab = new RadTab();
           tab.Text = "Tab";
           RadTabStrip1.Tabs.Add(tab);
           RadPageView pageView = new RadPageView();
           RadMultiPage1.PageViews.Add(pageView);
           BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count);
           RadTabStrip1.SelectedIndex = 0;
           RadTabStrip1.MultiPageID = RadMultiPage1.ID;
           RadTabStrip1.DataBind();
       }



Kind regards,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Babu Puchakayala
Top achievements
Rank 1
answered on 04 Jun 2010, 02:57 PM
Hi Peter,

Still its not working. Is there any other solution??
0
Peter
Telerik team
answered on 10 Jun 2010, 09:36 AM
Hello Babu,

I have attached a test page which shows that everything works correctly. Please, let me know if I am missing something.


Greetings,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Babu Puchakayala
Top achievements
Rank 1
answered on 10 Jun 2010, 03:31 PM
Hi Peter,

It works fine. Thanks.
Tags
TabStrip
Asked by
Babu Puchakayala
Top achievements
Rank 1
Answers by
Peter
Telerik team
Babu Puchakayala
Top achievements
Rank 1
Share this question
or