Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

setFocus issue

Posted on by 115

Hello,

We have a problem with setFocus on our Dynamics 365 Version 1612 (8.2.1.176).

When I set focus on General tab - it should be on top of the screen but after a second the focus is set to a subgrid above the general tab. I do not have any other setFocus functions and I observed that the height of window is changed in this function:

MicrosoftAjax.js

Function.createDelegate = function(a,b)
{
   return function()
   {
      return b.apply(a,arguments)
   }
};


Do you have any idea why is this happening and how to prevent the window to scroll up after I have set the focus to a tab? 

*This post is locked for comments

  • deno43 Profile Picture
    deno43 115 on at
    RE: setFocus issue

    Yes, nice thinking. This solved the problem we had, the focus stayed on general tab when I collapsed the tab that contained subgrids. Subgrids definitely are a problem here, will need to investigate this further.

  • Verified answer
    PranavShroti Profile Picture
    PranavShroti 4,510 on at
    RE: setFocus issue

    well this could be because of field order thats what I suspected. Anyways.

    I am not sure of the reason however as a workaround you can hide all other tabs and just make general tab visible and set focus. Check if that works.

    Regards,

    Pranav

  • deno43 Profile Picture
    deno43 115 on at
    RE: setFocus issue

    So after I set focus to a tab Xrm.Page.ui.tabs.get('general').setFocus(); - for a moment I can see "General tab" name and the fields in the tab on the top of the window, and after a second the window scrolls up and the "General tab" is located in the middle of the window which I do not want to beacuse I have set the focus earlier...

  • deno43 Profile Picture
    deno43 115 on at
    RE: setFocus issue

    I don't think you understood my problem. I have a piece of code that says Xrm.Page.ui.tabs.get('general').setFocus(); and suddenly after, the window scrolls up for no reason. This has nothing to to with tab on the keyboard...

  • Nausher Sayeed Profile Picture
    Nausher Sayeed 520 on at
    RE: setFocus issue

    Hi,

    The supported way is that to put the fields in sections of 1 row. Tab will going from up to down it goes to left to right.

  • PranavShroti Profile Picture
    PranavShroti 4,510 on at
    RE: setFocus issue

    Hi ddelic,

    This could be because of tab order of fields. The default tabbing order on CRM forms is top to bottom, left to right.

    you can write a small script to set the order:

    function SetTabOrderForFields() {

    for (var i = 0; i < Xrm.Page.ui.controls.getLength() ; i++)

    {

      var control = Xrm.Page.ui.controls.get(i);

      var element = document.getElementById(control.getName());

      if (element.tabIndex && element.tabIndex != "0") {

          if (element.className == 'ms-crm-Hidden-NoBehavior')

              continue;

          if (element.tagName == 'A') {

              if (element.className != 'ms-crm-InlineTabHeaderText')

                  continue;

          }

          element.tabIndex = 1000 + (i * 10);

      }

    }

    Hope this helps.

    Regards,

    Pranav

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans