10 Answers, 1 is accepted
If you do not want to call expensive operations in the item events of RadGrid (ItemCreated and ItemDataBound), you can call them in Page_Init before you start initializing your grid, load return values to variables (or arrays in case of many) and then in ItemDataBound check for the respective value of the variable and set the link visibility to false. In any case, the rendering of the grid on the browser is done after any manipulations with its items, so you will need to finish the operation before RadGrid is loaded.
See if this works for you.
the Telerik team
Thank you for the additional explanation.
You can loop through the items in the grid intercepting the DataBound or PreRender event of the control to perform some custom operation if needed.
In order to display the grid after the entire set of data is passed from the server and the control is rendered completely, consider ajaxifying the grid instance via RadAjaxManager/RadAjaxPanel and display a loading panel while the data is still processed. Review the documentation article linked below for further details:
the Telerik team
I have a grid that populates... and as it stands right now, the "view docs" link is the last item in the row...
if you press the link.. (as it is now) it will redirect to another page that makes a call out to SAP and combines a bunch of items and sometimes comes back with a link to a tif file or an array of them...
I want the grid to populate just like it does.. but i want that "view docs" link to be in an ajax panel.. so the loading gif would be displayed... (in other words, there would be a whole column of loading gifs... when the grid initially loads)
then.. i want to loop through the grid and make the call to SAP (via ajax)... if something comes back, i would make the view docs link active.. and take them another page that would display the link or links to the scanned (IXOS) documents.
If the array comes back empty, i would just leave the field empty or put an "n./a" there...
so the user would see the grid come up.. with all the data except for the "view docs" where they would see the loading gifs... and then... one by one.. as the call is made out to SAP, the loading gifs would be replaced by a link or an n/a.
I dont want to wait for all the data to come back as it would take a long time... SAP can be slow... especially when the servers reside halfway around the world...
having each piece of data come back...asynchronously is what i am trying to accomplish here..
I hope this helps to explain my quest here..
Unfortunately I do not think that the exact functionality you are searching for can be achieved. As a workaround you may consider making the loading panel sticky (setting its IsSticky property to true and positioning it at the desired location on the page) and displaying the ViewDocs links after the entire grid is loaded and rendered. I hope this is feasible solution for your situation.
the Telerik team
i just want to call a function that retrieves some data... and i dont want the client to have to wait for that data to come back... i want to make the call via ajax... and i dont know how.
in other words.. i want to load and render the grid...
and then AFTER the grid is rendered i would like to call another routine that loops through the grid..makes the call to SAP, and updates the grid row by row...
does this make sense?
Thank you for the additional explanation. In this case you can consider intercepting the PreRender event of RadGrid (when the data will be available on server) and invoke your routine which iterates through the grid records and updates them one by one. Finally, invoke the Rebind() method of the control to reflect the changes.
Alternatively, wire the OnGridCreated client event (when the grid object will be initialized on the client) and perform an ajax request via the ajaxRequest(eventSrc, eventArgs) method of RadAjaxManager (provided that you ajaxified the grid with ajax manager). Then inside the AjaxRequest handler update the grid data and once again call the Rebind() method to refresh it.
I hope these directions are helpful.
the Telerik team
I appreciate any insight to this...
Same scenario... I load up the grid... I set the "View" linkbutton .visible=false
Now, how would i make a call to the ValidateDocuments(); which would determine whether to make the linkbutton visible or not...
and secondly, since the linkbutton is in an ajax panel, how to i make it hit the itemcommand routine... (if it is visible and you press it, it never gets there until the page is refreshed)
Thanks for your help...
Here is the .aspx:
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="sb.Website._Default" %>
@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
ExpandCollapseColumn Visible="False" Resizable="False">
<telerik:GridBoundColumn DataField="TestID" DataType="System.Int32"
HeaderText="TestID" ReadOnly="True" SortExpression="TestID" UniqueName="TestID">
<telerik:GridBoundColumn DataField="MODULE" HeaderText="MODULE"
<telerik:GridBoundColumn DataField="STAGE" HeaderText="STAGE"
<telerik:GridBoundColumn DataField="PART" HeaderText="PART"
<telerik:GridBoundColumn DataField="SN" HeaderText="SN" SortExpression="SN"
<telerik:GridBoundColumn DataField="Docs" HeaderText="Docs"
SortExpression="Docs" UniqueName="Docs" Visible="False">
<asp:LinkButton runat="server" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton runat="server" CausesValidation="false" CommandName="Cancel"
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
<asp:LinkButton ID="btnView" runat="server" CausesValidation="false"
Here is the Code Behind:
public partial class _Default : System.Web.UI.Page
/// Handles the Load event of the Page class.
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
if (e.Item is GridDataItem)
GridDataItem item = (GridDataItem)e.Item;
LinkButton lb = new LinkButton();
lb = (
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
if (e.CommandName == "View")
protected bool ValidateDocuments()
bool docs = false;
//call to sap...
//get back an array...
//if array is empty.. bool = false;
//if array is not empty... bool = true;
I think that the best option for you might be to determine whether the view button inside the item template would be inside the ItemDataBound handler of the grid as shown here:
This will save you another iteration to traverse all grid items after they are loaded.
Additionally, if you want to ajaxify only a particular controls inside the grid, consider the solution presented in this KB article on our site which gives you greater flexibility:
Alternatively, you can ajaxify the entire grid instance through the ajax manager settings if you prefer. I hope that these directions will help you attain the functionality you are searching for.
the Telerik team