To test the functionality on this example:
- Click Next Page to initiate AJAX request
- Then click Toggle Colors to see the JavaScript is preserved after the AJAX request
Source Code & Description
The AJAX mechanism in Telerik RadGrid allows JavaScripts to be evaluated
after asynchonous requests to the server. The demo illustrates two scenarios
for using such functionality. There are two template columns in this grid.
The left column holds an item template with JavaScript code that is evaluated on
initual page load. The code holds some logic for browsing through a web galery of
images. When an AJAX request is performed, Telerik RadGrid will re-initialize
the JavaScript code and as a result the custom functionality will work properly.
The right column visualizes how a JavaScript code can be initialized on request.
The [Run] button will trigger an AJAX request that will load code from an external
JavaScript file, evaluated automatically by Telerik RadGrid.
This behavior is very important when working with third party controls that use
JavaScript and are loaded in template columns inside Telerik RadGrid.