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.
Best wishes,
Veli
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
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:
http://www.telerik.com/help/aspnet-ajax/ajxshowloadingpaneloninitialpageload.html
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
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...
ok...
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..
:)
Jeff
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.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
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?
jeff
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.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
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...
Jeff
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">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title>Home Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
<br />
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" GridLines="None"
onneeddatasource="RadGrid1_NeedDataSource" Skin="Vista"
onitemcommand="RadGrid1_ItemCommand" onitemcreated="RadGrid1_ItemCreated">
<
MasterTableView datakeynames="TestID">
<
RowIndicatorColumn Visible="False">
<
HeaderStyle Width="20px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn Visible="False" Resizable="False">
<
HeaderStyle Width="20px"></HeaderStyle>
</
ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="TestID" DataType="System.Int32"
HeaderText="TestID" ReadOnly="True" SortExpression="TestID" UniqueName="TestID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="MODULE" HeaderText="MODULE"
SortExpression="MODULE" UniqueName="MODULE">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="STAGE" HeaderText="STAGE"
SortExpression="STAGE" UniqueName="STAGE">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PART" HeaderText="PART"
SortExpression="PART" UniqueName="PART">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SN" HeaderText="SN" SortExpression="SN"
UniqueName="SN">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Docs" HeaderText="Docs"
SortExpression="Docs" UniqueName="Docs" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn">
<EditItemTemplate>
<asp:LinkButton runat="server" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton runat="server" CausesValidation="false" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
<asp:LinkButton ID="btnView" runat="server" CausesValidation="false"
CommandName="View" Text="View"></asp:LinkButton>
</telerik:RadAjaxPanel>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<
EditFormSettings>
<
PopUpSettings ScrollBars="None"></PopUpSettings>
</
EditFormSettings>
</
MasterTableView>
</telerik:RadGrid>
</div>
</form>
</
body>
</
html>
Here is the Code Behind:
#region
Using Directives
using
System;
using
System.Data;
using
System.Collections;
using
System.Configuration;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
sb.Data;
using
sb.Entities;
using
sb.Service;
using
Telerik.Web.UI;
#endregion
namespace
sb.Website
{
public partial class _Default : System.Web.UI.Page
{
/// <summary>
/// Handles the Load event of the Page class.
/// </summary>
/// <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)
{
RadGrid1.DataSource =
DataRepository.TestProvider.GetAll();
}
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
LinkButton lb = new LinkButton();
lb = (
LinkButton)item["TemplateColumn"].FindControl("btnView");
lb.Visible =
false;
}
}
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "View")
{
//redirect user
}
}
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;
return docs;
}
}
}
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:
http://www.telerik.com/help/aspnet-ajax/grdconditionalimagedisplayingridcolumn.html
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:
http://www.telerik.com/support/kb/article/b454K-ted-b454T-ceh-b454c-ceh.aspx
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.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center