RadGrid a Button and AJAX

7 posts, 2 answers
  1. SDI
    SDI avatar
    107 posts
    Member since:
    Nov 2011

    Posted 19 Dec 2011 Link to this post

    I have a RadGrid that is read-only. User clicks a "Create" button and it creates a new record to the grid with some default values already in place. I placed a ajaxManager and a ajaxPanel on the page. The manager points to the button as initiating the request and the grid as being updated by the request from the button. The button has "onClick=" to the server-side click event which adds a record for the grid. But this is not being hit first. Instead "NeedDataSource" of the grid then the "_Click" event (which has the rebind in it too), lastly the "PreRender" of the grid. Sadly the grid does not reflect the added record. It does pick up the last one when I click the "Create" again, due to the rebind grabbing the previous addition the the table.

    How can I avoid this? Why is the "NeedDataSource" being hit first before the actual button whom requested the call?

    Thanks
    SDI
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Dec 2011 Link to this post

    Hello SDI,

    Please have a look into the following documentation, which explain about ajaxifying Controls Wrapped in RadAjaxPanel and Added to RadAjaxManager Settings

    RadControls for ASP.NET AJAX Documentation

    Please paste your complete code if it doesn't help.

    -Shinu.
  3. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 20 Dec 2011 Link to this post

    Hi,

    Confirm that you do not have ViewState disabled for the grid. In this case the control fires NeedDataSource before the postback event:
    RadGrid Event Sequence

    Also, does the scenario work correctly with AJAX disabled?

    Best wishes,
    Tsvetina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  4. SDI
    SDI avatar
    107 posts
    Member since:
    Nov 2011

    Posted 20 Dec 2011 Link to this post

    Yes, the EnableViewState=True on the Grid, but FALSE on the MasterView, it was hidden at the end of the list Data/ClientKeyNames - DOH! Okay that is fixed and is hitting the events properly, thanks for the lead!

    However now something is happening with the AJAX Panel, it removes itself after the first update, but now does not hide itself after the second update. So, I click the Create button and it works great, then I click it again and the AJAXPanel stays over the grid.

    The AJAXPanel never goes away after the second button click...

    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" EnableViewState="True" />
      
    Thanks!
    SDI
  5. SDI
    SDI avatar
    107 posts
    Member since:
    Nov 2011

    Posted 21 Dec 2011 Link to this post

    I use a Rad Button and the sever side code gets hit the first round, the ajax panel shows and then its gone and new record appears in the grid. I click the button again and the ajax panel shows but it doesn't go to the server.

    <telerik:RadButton ID="RadButtonAddProgram" runat="server" Text="Create" OnClick="RadButtonAddProgram_Click"  />

    Is there another setting I need?

    EDIT: It DOES hit the server code again, it is working as it should, but the ajax panel will not hide itself. Why not, do I have to code for it to be removed?

    Thanks
    SDI
  6. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 22 Dec 2011 Link to this post

    Hello,

    Try running your page with script debugging enabled and check whether you get any client script errors. What you describe is not expected behavior, unless you have custom code for showing and hiding the loading panels. It is possible that you get multiple AJAX request breaking each other's functionality.

    Let us know if you observe any client errors and provide as much detail about them as possible.

    Kind regards,
    Tsvetina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  7. SDI
    SDI avatar
    107 posts
    Member since:
    Nov 2011

    Posted 22 Dec 2011 Link to this post

    Yes, it seemed to be invalid data coming back and erroring out in the script which was causing the ajax to fail. 

    Thanks!
    SDI
Back to Top