Using the response from DirectMethod in Renderer function

  1. #1

    Using the response from DirectMethod in Renderer function

    Hi! Help me, please!

    I have the DirectMethod. This method return the full username in string format

    [DirectMethod]
        public string GetFullDeclarantInfo(string user) // user = "D0\IVANOV_AA"
        {
            string trimDomain = @"D0\";
    
            SearchResult info = ADHelper.GetUserInfoByLogin(user.Trim(trimDomain.ToCharArray()));
            DirectoryEntry result = info.GetDirectoryEntry();
    
            return result.Properties["description"].Value as string; // "Ivanov Anton Antonovich"
        }
    I have GridPanel with Column for full usernames. I call Renderer function "declarantRenderer" for setting those usernames in each cell
    <ext:Column runat="server"
      DataIndex="DECLARANT_NAME"
      Text="Заявитель"
      Flex="1">
        <Filter>
          <ext:StringFilter />
        </Filter>
        <Renderer Fn="declarantRenderer"/>
    </ext:Column>
    And it is my Renderer function
    var declarantRenderer = function (value) {
      parent.App.direct.GetFullDeclarantInfo(value, {
         success: function (result) {
            return result;
          }
     });
       return result;
    };
    What wrong? Why I am getting empty cells? Help me, please..

    P.S. Excuse me for my bad english...
  2. #2
    Hello antifrizz! Welcome to Ext.NET forums!

    The result variable is only filled when the direct method's callback function is run. And it takes time. In other words, when the direct method finishes, the renderer will already have returned the undefined result the way you written it.

    What you can do is call something to "repaint" or "change" the rendered cell when coming back from the direct method.

    Try adding a console.log('result on renderer' + result); on your direct declarantRenderer function. You will notice only the callback one gets back in one piece.


    var declarantRenderer = function (value) {
      parent.App.direct.GetFullDeclarantInfo(value, {
         success: function (result) {
           console.log("Will print result value from callback scope: ");
           console.log(result);
           console.log("Should have printed it.");
            return result;
          }
     });
       console.log("Will print result value from renderer scope: ");
       console.log(result);
       console.log("Should have printed it.");
       return result;
    };
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Problem with DirectEvent function and response object
    By feanor91 in forum 3.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 25, 2015, 12:57 PM
  2. [CLOSED] DisplayField Re-Run Renderer Function
    By Sobhia in forum 3.x Legacy Premium Help
    Replies: 5
    Last Post: Jun 05, 2015, 7:36 AM
  3. [CLOSED] Renderer function
    By tanky65 in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 30, 2012, 7:21 PM
  4. Replies: 24
    Last Post: Feb 13, 2012, 3:39 PM
  5. [CLOSED] Accessing Row value in row click renderer function
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jun 09, 2009, 4:11 AM

Tags for this Thread

Posting Permissions