locked
Tab control click event RRS feed

  • Question

  • For performance reasons, (on the silverlight client) I need to be able to load grids and lookups on inactive tabs only when the tab is actually clicked. I see that there is an event that we can create to force the change of a tab but I cant seem to find one that fires when a tab is actually changed...

    does anyone have any suggestions?

    Thanks in advance

    Adam

     
    Thursday, January 29, 2015 6:42 PM

Answers

  • Hi

    My solution to you problem is like this:

    First you unmark "Auto Execute Query" on the data item source.  

    Then If you have a "Tab Layout" with a "Tab Item" named TAB1 you add the following code in the screens Created event.

    this.FindControl("TAB1").ControlAvailable += TAB1_Avaliable;

    Then the implement the function TAB1_Avaliable that will fire when the TAB is activated (clicked).

    private void TAB1_Avaliable(object sender, ControlAvailableEventArgs e)        
    {   
       this.<yourgrid>.Refresh();
    }

    Regards FreLar

    • Marked as answer by Angie Xu Monday, February 9, 2015 1:43 AM
    Saturday, January 31, 2015 9:20 PM

All replies

  • this is an amazing bit of code. However I am reluctant to use code in my clients app as a) I dont understand it, b) I probably will never understand and c) its a bit overkill for a simple solution.  

    A simple TabClicked event would be fantastic if anyone has an example....

    Thanks

    Adam

     

    Friday, January 30, 2015 3:06 PM
  • Agreed, this is not simple code.  I don't know of an easier way besides turning Auto-Execute Query to false and calling MyQuery.Load() in a method that fires when the tab is clicked (don't recall a specific name for that event).  The drawback with that approach though is that you have to manually implement all of the behavior you get out of the box with auto-execute query, such as paging and sorting etc.  That is why I believe the code in Jan's example is so involved; he is working around that.
    • Edited by Hessc Friday, January 30, 2015 5:42 PM
    Friday, January 30, 2015 5:41 PM
  • Thanks for your response, its good advice. I wasnt aware that turning off Autoexecute on queries prevents sorting, paging etc....I've just tested it and and while paging only works if you re-load the query everything else still seems to work...am I confused somewhere?

    I'm surprised others haven't asked for a TabClicked as I would have thought it would be a common feature / problem.

    Hey thanks again for your help

    Saturday, January 31, 2015 6:49 PM
  • Hi

    My solution to you problem is like this:

    First you unmark "Auto Execute Query" on the data item source.  

    Then If you have a "Tab Layout" with a "Tab Item" named TAB1 you add the following code in the screens Created event.

    this.FindControl("TAB1").ControlAvailable += TAB1_Avaliable;

    Then the implement the function TAB1_Avaliable that will fire when the TAB is activated (clicked).

    private void TAB1_Avaliable(object sender, ControlAvailableEventArgs e)        
    {   
       this.<yourgrid>.Refresh();
    }

    Regards FreLar

    • Marked as answer by Angie Xu Monday, February 9, 2015 1:43 AM
    Saturday, January 31, 2015 9:20 PM
  • I tried to use the code above and its pretty neat. Thank you!

    But I have a question, how to put the datagrid's selected item on my detail column? I have 3 tab layouts with a datagrid on each tab...

    Friday, August 26, 2016 7:17 AM