JBCuery tabcontrol: load gridview

I have a JQuery / CSS tabcontrol that is currently handling 4 tabs containing gridviews. I want the gridview to be loaded when you click on the tabs. This reduces page load times as some of the gridview scrolling takes a while. The gridviews need to be loaded once, they don't need to be refreshed every time you open a particular tab.

JQuery

$(document).ready(function() 
{ 
    //When page loads... 
    $(".tab_content").hide(); //Hide all content 
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab 
    $(".tab_content:first").show(); //Show first tab content 

    //On Click Event 
    $("ul.tabs li").click(function() 
    { 
        $("ul.tabs li").removeClass("active"); //Remove any "active" class 
        $(this).addClass("active"); //Add "active" class to selected tab 
        $(".tab_content").hide(); //Hide all tab content 

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content 
        $(activeTab).fadeIn(); //Fade in the active ID content 
        return false; 
    }); 
});

      

Now I just started using JQuery so I really don't know how to deal with this ... Any ideas?

+2


a source to share


2 answers


I had a similar problem. What I did was create a button to load the gridview, and in the select event for jquery tabs, I click those buttons. Something like that:



$("#tabs").tabs({
        select: function (event, ui) {
            switch (ui.index) {
                case 0:
                    $("#<%= btnOne.ClientID %>").click();
                    break;
                case 1:
                    $("#<%= btnTwo.ClientID %>").click();
                    break;
                case 2:
                    $("#<%= btnThree.ClientID %>").click();
                    break;
            }
        }
 });

      

+1


a source


If you want to do everything on the server you need an update panel and force the postback with __doPostBack so the server can handle the request ... You can also use $ .ajax for that, okay ...

Otherwise, do it all on the client, pass the data to the client from the web service, and create a table on the client.



NTN.

0


a source







All Articles