Problem with client RowSelected() event in Mozill Firefox

15 posts, 0 answers
  1. Pandu
    Pandu avatar
    38 posts
    Member since:
    Sep 2009

    Posted 14 Jun 2010 Link to this post

    Dear Telerik Team,

    I am using a RadGrid and loading Item values on page load. When i click on Row I need to fire OnClientRowSelected event which is working well in IE but causing problem in MozillaFirefox by showing undefined. Where i need to load RadEditor with some values.

    Thanks Inadvance

    Regards
    ----------
    Pandu
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 17 Jun 2010 Link to this post

    Hello Pandu,

    We need some more details to be able to better understand your scenario. Are you using client-side binding? What is the message of the javascript error you are getting? If you can provide us some sample code we can examine, we will be able to identify the cause for the exception.

    Kind regards,
    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Charlie
    Charlie avatar
    7 posts
    Member since:
    Jul 2010

    Posted 13 Jul 2010 Link to this post

    I'm having a similar problem. My process flows like this:

    Note: I am using the 2009.3.1314.35 Telerik controls (which if I'm correct, are the Q3 2009 controls)

    I have a RadGrid with an OnRowClick="RowSelected" ClientEvent.

    My RowSelected javascript function:

            function RowSelected(sender, eventArgs) {
                var ajaxManager = $find('PageAjaxManager');
                ajaxManager.ajaxRequestWithTarget('lnkPopulate', '');
            }

    That then hits the PageAjaxManager to update the lnkPopulate control, which has an OnClick value of lnkPopulate_Click.

    The first thing to happen in my lnkPopulate_Click function in my C# code is:

            foreach (GridDataItem gdi in grid.SelectedItems)

    In Firefox 3.6 and Chrome 5.0 (and quite possibly Safari, though I have not tested this), grid.SelectedItems is 0. In Internet Explorer 8 (running in IE7 Compatibility mode), grid.SelectedItems is 1. Is there something special I need to do to make this functionality work cross-browser?

    (Sorry in advance for not having code blocks for the code...I can't figure out how to do them)
  5. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 14 Jul 2010 Link to this post

    Hi Charlie,

    You need to make sure the AJAX manager updates both RadGrid and the LinkButton in this case:

    <telerik:RadAjaxManager ID="PageAjaxManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="PageAjaxManager">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    <telerik:AjaxUpdatedControl ControlID="lnkPopulate" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    You can also use an alternative approach to implement this scenario. RadGrid can postback when a row is selected automatically. You need set:

    <ClientSettings EnablePostBackOnRowClick="true">
        <Selecting AllowRowSelect="true" />
    </ClientSettings>

    You can then subscribe to RadGrid's ItemCommand event and handle your logic there:

    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "RowClick")
        {
            //either invoke the CLick event handler of the link button
            //or iterate through the selected grid items right here
        }
    }

    Any of these two approaches should work for you. If they don't, we are going to have to look at some code to further advise you.

    All the best,
    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Charlie
    Charlie avatar
    7 posts
    Member since:
    Jul 2010

    Posted 14 Jul 2010 Link to this post

    Thanks Veli! That second solution worked out great for me!
  7. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 03 Aug 2010 Link to this post

    There is certainly still a problem with this in Firefox.
    I'm using the latest 2010 Q2 controls.
    Latest IE and Firefox.

    My web application project under IE works perfectly with respect to the ClientSettings/ClientEvents "OnRowClick" event processing.

     

     

    <ClientSettings>

     

     

     

    <Selecting AllowRowSelect="true" />

     

     

     

    <ClientEvents OnRowClick="onRadGridPersonVIEW_RowSelected" />

     

     

     

    </ClientSettings>

     


    The event DOES fire on firefox, but the problem is that when you handle the event and process the ajax request server-side the RADGRID does NOT have the RADGRID.SelectedValue assigned correctly (per the OnRowClick that just happened).  I have debugged it extensively and it seems to be one click behind in firefox.  So, the initial "click" on a grid row produces NOTHING for the RADGRID.SelectedValue.  Any subsequent clicks of a row will produce a RADGRID.SelectedValue FROM THE PREVIOUS CLICK (not the current clicked row).  This happens like clockwork.  In IE, the RADGRID.SelectedValue is always for the CURRENT click in this same process.

    My ajaxRequest stuff is pretty standard and again....works perfectly under IE:

     

     

    function onRadGridPersonVIEW_RowSelected(sender, args) {

     

     

     

    var ajaxManager = $find("<%= myAjaxManager.ClientID %>");

     

    ajaxManager.ajaxRequest(

     

    "RadGridPersonVIEW_RowSelected");

     

    }



    Can we get a fix for this??
    It makes the ClientSettings/ClientEvents OnRowClick pretty unuseable at the moment with this behaviour in Firefox.  I mean... there has to be a reason why it works in IE and NOT firefox.

    Now, I know there are workarounds...  Some that I have played with and implemented have to do with setting the "ClientDataKeyNames" on MasterTableView...retriving that value (key that you clicked on in the grid) in the args of the JS function and passing it along in some way or another.  Another way (which is my current method since I hit this road block) is to just set the "EnablePostBackOnRowClick" on the ClientSettings to trigger the RADGRID SelectedIndexChanged event.  That seems to work and maybe is easier overall for this case, but it scares me a bit that firefox wouldn't work for the original method.... scares me in the sense that "what else" won't firefox work with that seems pretty simple that IE handles with RADGRID.

    Thanks.
  8. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 05 Aug 2010 Link to this post

    Hello Shawn,

    Try the client-side OnRowSelected event instead. This will fire after the row has been selected and the grid updates its state to reflect the selection:

    <ClientSettings>
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowSelected="onRadGridPersonVIEW_RowSelected" />
    </ClientSettings>


    Regards,
    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Mauricio Chotocruz
    Mauricio Chotocruz avatar
    4 posts
    Member since:
    Mar 2007

    Posted 09 Aug 2010 Link to this post

    Hello,

    I got the same issue, I try OnRowSelected and OnClick and doesn't work at all, i can't get the SelectedValue. The problem is in firefox, safari, chrome.

    Did you find a solution?

  10. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 11 Aug 2010 Link to this post

    Hi Mauricio,

    OK, let's try another approach. When you have row selection and postback on row click enabled for RadGrid:

    <ClientSettings>
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowSelected="onRadGridPersonVIEW_RowSelected" />
    </ClientSettings>

    RadGrid fires its server-side SelectedIndexChanged event:

    protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
    {
        foreach (GridDataItem selectedItem in RadGrid1.SelectedItems)
        {
            //...
        }
    }

    You can use that to get to the selected items on the server. If this is not what you meant, or what you need, can you explain further?

    All the best,
    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Mauricio Chotocruz
    Mauricio Chotocruz avatar
    4 posts
    Member since:
    Mar 2007

    Posted 12 Aug 2010 Link to this post

    Hi, 

    I open a radwindow, from this window i want to refresh the grid that is in the parent window. Something like this:

    Parent Window:

    RadGrid:
    ...
     
    <ClientSettings>                          
                <Selecting AllowRowSelect="True"/>
                <ClientEvents OnRowClick="RowClick"/>
    </ClientSettings>
     
    .......
     
    Javascript:
     
     function RefrescaGrid()
         {                                      
            $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest();               
         }
     
    .......
     
    VB:
     
     Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            Dim RadAjaxManager1 As RadAjaxManager = CType(Master.FindControl("RadAjaxManager1"), RadAjaxManager)
            Dim handler As New RadAjaxControl.AjaxRequestDelegate(AddressOf Me.WebUserControl_AjaxRequest)
            AddHandler RadAjaxManager1.AjaxRequest, handler
        End Sub
     
        Sub WebUserControl_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
            Dim vlbo_Expediente As New ExpedienteBO      
            Try           
                rg_Descriptores.DataSource = vlbo_Expediente.ObtieneCamposDescriptor(rg_Extractos.SelectedValue)
                rg_Descriptores.DataBind()           
            Catch ex As Exception
            Finally
                vlbo_Expediente = Nothing
            End Try
        End Sub
     
        Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
            Dim RadAjaxManager1 As RadAjaxManager = CType(Master.FindControl("RadAjaxManager1"), RadAjaxManager)
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, Panel1, RadAjaxLoadingPanel1)
        End Sub

    Child Window:

    <script type="text/javascript">                            
                 
                function CloseAndRebind() {                
                    self.close();
                    window.opener.RefrescaGrid();                               
                }
                                                             
    </script>
     
    .......
     
    ' On a button I call the CloseAndRebind javascript function:
     
     ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", True)

    When I selected a row in the rg_Extractos RadGrid, I show the rg_Descriptores RadGrid. When I closed the child window, the rg_Extractos.SelectedValue contains the DatakeyValue of the Row selected. But this only works fine in Internet Explorer. 

    I hope you understand...


  12. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 16 Aug 2010 Link to this post

    Hello Mauricio,

    When you rebind the grid, its data items are recreated and restored to their default state, so you lose the selection so far. If you want to preserve the selected items, you will have to save their data key values before rebinding the grid and restoring their Selected state on PreRender after the grid is rebound.

    To rebind a parent grid from a child window, you can get RadWindow instance from the child window and call the $find() method of the BrowserWindow to find the RadGrid component in the parent window. For example, most RadWindow and RadGrid examples have a GetRadWindow() function in the child window returning the RadWindow client object from the parent browser window. Using that, you can have:

    //GetRadWindow().BrowserWindow gives you the parent browser window object
    //its $find() method will work to find client components in the parent window
    //we can use that to find the RadGrid client component
    var parentGrid = GetRadWindow().BrowserWindow.$find("RadGrid1");
    parentGrid.get_masterTableView().rebind(); //rebind the master table


    Regards,
    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Mauricio Chotocruz
    Mauricio Chotocruz avatar
    4 posts
    Member since:
    Mar 2007

    Posted 17 Aug 2010 Link to this post

    Hi Veli,

    What I'm doing is "rg_Descriptores.DataBind()", no "rg_Extractos.DataBind()". I'm obtaining the value of the selected row of radgrid "rg_Extractos". As I said before everything works well in IE, but not in Chrome, Firefox and Safari.

    rg_Descriptores.DataSource = vlbo_Expediente.ObtieneCamposDescriptor(rg_Extractos.SelectedValue)
    rg_Descriptores.DataBind()

    rg_Descriptores is the "child" Radgrid.

    Regards,
  14. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 19 Aug 2010 Link to this post

    Hello Mauricio,

    On 08/12 you said:

    I open a radwindow, from this window i want to refresh the grid that is in the parent window.

    Now, is it the other way? Can you, please, clarify, along with the exact steps you are taking and the result. Also state clearly what is not working and what are you getting - an error, unexpected values, nothing at all?

    If you obtain the selected value of the  parent window grid into the child window, how do you do that? From your code-behind:

    rg_Descriptores.DataSource = vlbo_Expediente.ObtieneCamposDescriptor(rg_Extractos.SelectedValue)
    rg_Descriptores.DataBind()

    I am left with the impression both grids are on one and the same page. Can you clarify these things.

    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Mauricio Chotocruz
    Mauricio Chotocruz avatar
    4 posts
    Member since:
    Mar 2007

    Posted 19 Aug 2010 Link to this post

    Hello,

    Yes, both grids are on the same page. I have a button that open a child Window, from this child Window I want to refresh the Grid2 (rg_Descriptores) counting on the actual selected row on the Grid1 (rg_Extractos).

    I get the actual selected row of the Grid1 (rg_Extractos)  on Internet Explorer but not in Chrome, FireFox and Safari.

    I hope you understand me...

    Regards,

  16. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 20 Aug 2010 Link to this post

    Hello Mauricio,

    Attaching a test page to demonstrate this scenario.

    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017