Client API OnPopUpShowing: eventArgs.get_domEvent() is not a function

9 posts, 0 answers
  1. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 23 Apr 2009 Link to this post

    Hi,

    After reading some threads and documentation about the client-side OnPopUpShowing event, I tried to position the popup window right below the edited item (as opposed to centered in the page as discussed in this thread)

    I tried using the eventArgs.get_domEvent() function but received the following error : eventArgs.get_domEvent is not a function. My objective was to retrieve the clicked button's image and deduced the position from there. The documentation page about OnPopUpShowing mentions that domEvent is an property of eventArgs though...

    1 var popUp; 
    2 function PopUpShowing(sender, eventArgs) 
    3
    4    var  domEvent = eventArgs.get_domEvent(); 
    5    var target = domEvent.target; 
    6    ... 
    7

    Can you suggest an alternative ?

    Dominic.
    -----
    Using version 2009 Q1 SP1 (2009.1.402.35)
  2. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 23 Apr 2009 Link to this post

    Hi,

    I'm not very clear why you want to get the dom_Event and then the target (which I guess you expect to be the Popup).
    Fact is, that eventarg gives you two things in this case - access to cancel - and via "get_popUp" access to the Popup.

    And sender gives you access to the grid itself.
    By the way - I took a look at the thread you linked - I could not find any code (of course) which uses get_domElement().

    Regards

    Manfred
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 23 Apr 2009 Link to this post

    Hi Manfred, thanks for the reply,

    Did you check the documentation page I linked to (http://www.telerik.com/help/aspnet-ajax/onpopupshowing.html) ?

    Here's an excerpt :

    Arguments

    popUp - html element of the pop-up edit form

    domEvent - dom event


    As mentioned, I had hoped the DOM event's target would be the button clicked, not the popup itself, but the actual element clicked to cause the popup to open. With that DOM element, I would be able to get its actual position on the screen and then position the popup accordingly...

    Note, it's domEvent, not domElement in the documentation. So my question really is two-fold :

    1- Is the documentation incorrect or am I reading it wrong ?
    2- How can I position the popup relative to the edited row ?

    Thanks,

    Dominic.
  5. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 23 Apr 2009 Link to this post

    Follow up:

    If you want to handle the edit button yourself (custom button) you can (from the Button client handler) bring your Item into EditMode with this function: http://www.telerik.com/help/aspnet-ajax/grid_edititem.html
    So you get your button's attributes in your "private function" - and can save it for later use in OnPopUpShowing.
  6. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 23 Apr 2009 Link to this post

    Jep, I'v seen this domEvent sometimes in documentation - I ignored it :)

    I could not find a method to retrive the currently edited element from client code.
    There is a sample here http://www.telerik.com/community/forums/aspnet-ajax/grid/dataitem-is-in-editmode-on-client-side.aspx but for my approach this was to much.
    If you can get the dataitem (you'r editing at the moment) you won - there is http://www.telerik.com/help/aspnet-ajax/grid_control_row.html get_element() which gives you access to the table row - finding the button from there would mean nothing.

    If no one has a better idea - I would use a hidden field to save my current edit index.
    With this you can access the element in your OnShowPopup.
    So on Server
            protected void rgTest_EditCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) {  
                hfEditItem.Value= e.Item.ItemIndex.ToString();  
            }  
     
    On client:
            function OnShowPop(sender, args) {  
                var hfVal = document.getElementById(("<%= hfEditItem.ClientID %>"));  
                var rGrid = $find("<%= rgTest.ClientID %>");  
                var rMaster = rGrid.get_masterTableView();  
     
                var el=rMaster.get_dataItems()[hfVal.value].get_element();  
                //el is the table row...  
            }  
    ...  
    <asp:HiddenField ID="hfEditItem" runat="server" /> 
    I wanted to show a working solution -- my problem at the moment -- get_masterTableView() always returns null - except I call it in a "OnCommand" handler - there it works!!
    But I guess this is a fault of my "rough and dirty" test project.

    Regards

    Manfred
  7. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 01 May 2009 Link to this post

    Thanks for your suggestion. But, can someone from Telerik confirm that the get_domEvent() specified in the documentation is not implemented properly?

    Is there any intention of fixing the API (or the doc), that would help me orient my solution.

    Thanks,

    dstj.
  8. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 03 May 2009 Link to this post

    Hi dstj,

    simply use the debugger and take a look at args with this call.
    You'll see that you can get only "get_cancel, set_cancel and get_popUp" from this parameter.

    And my "idea" will also not work - since get_mastTableView is not working in this case.
    Take a look at this thread: http://www.telerik.com/community/forums/aspnet-ajax/grid/get-mastertableview-not-always-working.aspx

    Regards

    Manfred

  9. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 03 May 2009 Link to this post

    My question for the Telerik dev team remains (you really can't help me there): is the API wrong or the documentation wrong, they contradict themselves? Which one will be fixed?
  10. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 05 May 2009 Link to this post

    Hello Dominic,

    I am afraid that it was the documentation that misleaded you. There is no domEvent  in the arguments.
    We will fix the documentation immediately.

    Greetings,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017