Treeview focus() problem!

Discussion in 'ASP .Net Web Controls' started by Shridhar, Feb 10, 2005.

  1. Shridhar

    Shridhar Guest

    Hi,

    We have a problem of treeview focus() when the page is loaded. Basically we
    are using it in webpart.(something like a frame) on pageload we tried with
    document.getElementById('Treeviewpanel').focus(), but it seems not working!
    Our custom tooltip will not display in proper position. as our business
    logic calculates the coordinates when click or focus is fired on treeview
    panel.

    Any clue to calculate the coodinates or focus on Treeview panel is
    appreciated.

    Thanks,
    Shridhar
     
    Shridhar, Feb 10, 2005
    #1
    1. Advertising

  2. Shridhar

    JamesHead Guest

    Hi,

    not sure how much this will help, but it might be worth checking (using view
    source) the actual id of the treeview control. If you are planning to have
    more than one treeview control on the page (or more than one instance of that
    webpart on the page) then you should use something similar to the following:

    c# -
    tree = new TreeView();
    tree.Attributes.Add("id", ReplaceTokens("oTree_WPQ_"));

    this will add a client side id related to the id of the webpart. When
    rendered, the ReplaceTokens function will seek "_WPQ_" and replace it with
    "WPQx" where x is the id of the webpart. You will also need to reflect this
    change in the javascript. Chances are you will have to pass in this id into
    the javascript function in this fashion:

    c# -
    output.Write(ReplaceTokens("<script>myfunction('oTree_WPQ_');</script>"));

    Hope this helps - if it does, please post back to let me know. If you need
    me to look over some code, ping some back and I will endeavour to have a
    look. I am currently working on a treeview webpart and have solved several of
    these problems recently.

    Regards,

    James

    "Shridhar" wrote:

    > Hi,
    >
    > We have a problem of treeview focus() when the page is loaded. Basically we
    > are using it in webpart.(something like a frame) on pageload we tried with
    > document.getElementById('Treeviewpanel').focus(), but it seems not working!
    > Our custom tooltip will not display in proper position. as our business
    > logic calculates the coordinates when click or focus is fired on treeview
    > panel.
    >
    > Any clue to calculate the coodinates or focus on Treeview panel is
    > appreciated.
    >
    > Thanks,
    > Shridhar
    >
     
    JamesHead, Feb 10, 2005
    #2
    1. Advertising

  3. Shridhar

    Shridhar Guest

    Hi James

    Thanks. Offcourse I am getting dynamic id(treeviewpanel/catalogtree) which
    is something like
    "MiddleLeftZone_g_ea3d89d3_93d1_434f_88cb_c10fe2f2641b__ctl1_CatalogTree"

    but when I use thisid .focus() and if I add alert, this shows 'undefined.' I
    think the treeview.htc also has some dofocus(), cancelfocus()/changefocus()
    etc.(IE webcontrol tree) so it conflicts with our focus.
    If I do not use focus in my onhover function, first time it displays in
    wrong position. on click on the panel it displays on the proper position.
    again when focus lose, it display wrong position(if clicks someother places
    other than the panel).I have used for event.clientX and event.clientY for x
    and y coordinates.

    Note that this happens only when I set the height and width of the webpart.
    if the height and width is relative, the custom description displays fine,
    all the condition.


    Thanks,
    Shridhar.

    "JamesHead" wrote:

    > Hi,
    >
    > not sure how much this will help, but it might be worth checking (using view
    > source) the actual id of the treeview control. If you are planning to have
    > more than one treeview control on the page (or more than one instance of that
    > webpart on the page) then you should use something similar to the following:
    >
    > c# -
    > tree = new TreeView();
    > tree.Attributes.Add("id", ReplaceTokens("oTree_WPQ_"));
    >
    > this will add a client side id related to the id of the webpart. When
    > rendered, the ReplaceTokens function will seek "_WPQ_" and replace it with
    > "WPQx" where x is the id of the webpart. You will also need to reflect this
    > change in the javascript. Chances are you will have to pass in this id into
    > the javascript function in this fashion:
    >
    > c# -
    > output.Write(ReplaceTokens("<script>myfunction('oTree_WPQ_');</script>"));
    >
    > Hope this helps - if it does, please post back to let me know. If you need
    > me to look over some code, ping some back and I will endeavour to have a
    > look. I am currently working on a treeview webpart and have solved several of
    > these problems recently.
    >
    > Regards,
    >
    > James
    >
    > "Shridhar" wrote:
    >
    > > Hi,
    > >
    > > We have a problem of treeview focus() when the page is loaded. Basically we
    > > are using it in webpart.(something like a frame) on pageload we tried with
    > > document.getElementById('Treeviewpanel').focus(), but it seems not working!
    > > Our custom tooltip will not display in proper position. as our business
    > > logic calculates the coordinates when click or focus is fired on treeview
    > > panel.
    > >
    > > Any clue to calculate the coodinates or focus on Treeview panel is
    > > appreciated.
    > >
    > > Thanks,
    > > Shridhar
    > >
     
    Shridhar, Feb 10, 2005
    #3
  4. Shridhar

    Shridhar Guest

    I have used like
    if((Wpheight != "")||(Wpwidth != ""))
    {
    tipX = event.clientX;
    tipY = event.clientY + offset; //141.. offeset I am calculating

    // tipX = event.offsetX;
    // tipY = event.offsetY;
    }
    else
    {
    //this part works perfectly all the conditions.
    tipX = window.event.x + 10 +document.body.scrollLeft ;
    tipY = window.event.y +document.body.scrollTop +10;
    }
     
    Shridhar, Feb 10, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Claus
    Replies:
    3
    Views:
    12,276
    ironste
    Sep 7, 2006
  2. Jason
    Replies:
    4
    Views:
    1,681
    Jason
    May 7, 2007
  3. Chris van Renen

    TreeView Problem - Setting focus on current Node causes scrolling

    Chris van Renen, Jun 13, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    181
    Chris van Renen
    Jun 13, 2005
  4. Replies:
    2
    Views:
    357
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    379
Loading...

Share This Page