Deleting dynamic pageviews using Javascript

7 posts, 0 answers
  1. Babu Puchakayala
    Babu Puchakayala avatar
    79 posts
    Member since:
    May 2010

    Posted 26 May 2010 Link to this post

    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>  

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 01 Jun 2010 Link to this post

    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.
  3. Babu Puchakayala
    Babu Puchakayala avatar
    79 posts
    Member since:
    May 2010

    Posted 01 Jun 2010 Link to this post

    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); 
        } 
     

  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 04 Jun 2010 Link to this post

    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.
  5. Babu Puchakayala
    Babu Puchakayala avatar
    79 posts
    Member since:
    May 2010

    Posted 04 Jun 2010 Link to this post

    Hi Peter,

    Still its not working. Is there any other solution??
  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 10 Jun 2010 Link to this post

    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.
  7. Babu Puchakayala
    Babu Puchakayala avatar
    79 posts
    Member since:
    May 2010

    Posted 10 Jun 2010 Link to this post

    Hi Peter,

    It works fine. Thanks.
Back to Top