This is a migrated thread and some comments may be shown as answers.

updateItem & subsequent AJAX calls

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 28 Aug 2009, 12:43 PM
I have some javascript which calls the "updateItem" method to update an edited row in my radgrid.

The updateItem method works fine except for when I call another AJAX grid method right after it such as "editItem" (for a different row).

It appears that the two asynchronous calls are colliding with each other with the second call causing the first one to never successfully complete.

Is there a way to call "updateItem" in a synchronous manner?  Or is there a way to capture an event on the client in javscript when the updateItem method finishes so that I can call my second AJAX method thereby eliminating the collision?

My workaround right now is to call updateItem and then set a timeout to make the second AJAX call.  This works ok over a reliable connection because by the time the timeout calls the second method the first one has "almost always" finished.  Clearly though it would be better to not call the second until I know for a fact the first one ran successfully.

Any thoughts?

1 Answer, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 1
answered on 29 Aug 2009, 07:25 PM

I think I solved my problem.  It seems that most (if not all) GridTableView AJAX calls fire the "OnMasterTableViewCreated" event when they complete.  So all I had to do was assign a function to handle the event and then within that function call a pointer to the desired javascript function.  I would set this pointer right before making the AJAX call.  Here is some sample code:

 

    <telerik:RadGrid ID="SalesForceGrid" runat="server">  
        <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" DataKeyNames="Id" InsertItemDisplay="Bottom" EnableColumnsViewState="false" /> 
        <ClientSettings> 
            <ClientEvents OnRowClick="RowClick" OnMasterTableViewCreated="MasterTableViewCreated" /> 
        </ClientSettings> 
    </telerik:RadGrid> 

 

            window.afterCallBack = null;  
 
            function MasterTableViewCreated() {  
                if (window.afterCallBack != null)  
                    window.afterCallBack();  
            } 

window.afterCallBack = function() { FocusFirstColumnControl(false); };  
masterTableView.editItem(window.editRowIndex); 

 

 

 

 

 

 

 

 

 

 

 

 

Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Eric
Top achievements
Rank 1
Share this question
or