Hello,
I am testing the Telerik Demo, to see how I can use the components for the company I work for. I am using a RadGrid (with a template column that contains some image buttons). The grid is inside a RadPageView, inside a RadMultiPage inside a LoginView. I use master pages (radajaxmanager on master page, and proxy on content page).
When I click on of the aforementioned image buttons, a window opens up, passing a value in the query string. When the window is closed the grid rebinds (or at least thats the intention). However, I've be having some problems. As desscribed by the following steps:
Heres my code:
Content Page
...
...
...
...
AND my Window Code
...
Any ideias?
Thanks in Advance
I am testing the Telerik Demo, to see how I can use the components for the company I work for. I am using a RadGrid (with a template column that contains some image buttons). The grid is inside a RadPageView, inside a RadMultiPage inside a LoginView. I use master pages (radajaxmanager on master page, and proxy on content page).
When I click on of the aforementioned image buttons, a window opens up, passing a value in the query string. When the window is closed the grid rebinds (or at least thats the intention). However, I've be having some problems. As desscribed by the following steps:
- When I click the image button the first time the query string parameter is correct (Ex.: Query string is "Form.aspx?row=1") , I close the window and the grid is refreshed.
- I click again on a different row I get the value from the previous window (Ex.: should get "Form.aspx?row=2" but I get the previous value "Form.aspx?row=1").
- I try clicking again the same row (or any other row) and this time I get the right value passed in the query string (Ex.: "Form.aspx?value=2"). BUT I'm back at step 1 again.
Heres my code:
Content Page
protected void Page_PreRender(object sender, EventArgs e) |
{ |
RadGrid grid = (RadGrid)LoginView1.FindControl("RadMultiPageMain").FindControl("PageViewTarefas").FindControl("RadGridTarefas"); |
string s = RadAjaxManager.GetCurrent(this.Page.Master.Page).ToString(); |
RadAjaxManager RadAjaxManager1 = ((RadAjaxManager)Page.Master.FindControl("RadAjaxManager1")); |
RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, grid); |
} |
protected void Page_Init(object sender, EventArgs e) |
{ |
RadAjaxManager radajaxManager = (RadAjaxManager)this.Page.Master.FindControl("RadAjaxManager1"); |
RadAjaxControl.AjaxRequestDelegate handler = new RadAjaxControl.AjaxRequestDelegate(this.RadAjaxManagerProxy1_AjaxRequest); |
radajaxManager.AjaxRequest += handler; |
} |
protected void RadGridTarefas_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem dataItem = (GridDataItem)e.Item; |
ImageButton imgBut = (ImageButton)dataItem["TmpltColTaskCmds"].FindControl("ImgEditButton"); |
//imgBut.Attributes["href"] = "#"; |
imgBut.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["id_tarefas_trfs"], e.Item.ItemIndex); |
} |
} |
protected void RadAjaxManagerProxy1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
RadGrid grid = (RadGrid)LoginView1.FindControl("RadMultiPageMain").FindControl("PageViewTarefas").FindControl("RadGridTarefas"); |
if (e.Argument == "Rebind") |
{ |
grid.MasterTableView.SortExpressions.Clear(); |
grid.MasterTableView.GroupByExpressions.Clear(); |
grid.Rebind(); |
} |
else if (e.Argument == "RebindAndNavigate") |
{ |
grid.MasterTableView.SortExpressions.Clear(); |
grid.MasterTableView.GroupByExpressions.Clear(); |
grid.MasterTableView.CurrentPageIndex = grid.MasterTableView.PageCount - 1; |
grid.Rebind(); |
} |
} |
<%@ Page Language="C#" MasterPageFile="~/TaskMaster.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %> |
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> |
<asp:Content ID="ContentContent" ContentPlaceHolderID="ContentPlaceHolderContent" Runat="Server"> |
<asp:LoginView ID="LoginView1" runat="server"> |
<LoggedInTemplate> |
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadGridTarefas"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGridTarefas" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AjaxControlID="RadAjaxManagerProxy1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGridTarefas" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManagerProxy> |
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
<script type="text/javascript"> |
function ShowEditForm(id, rowIndex) { |
var grid = $find('<%= this.LoginView1.FindControl("RadMultiPageMain").FindControl("PageViewTarefas").FindControl("RadGridTarefas").ClientID %>'); |
var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); |
grid.get_masterTableView().selectItem(rowControl, true); |
window.radopen("EditTaskForm.aspx?id_tarefas_trfs=" + id, "EditTaskDialog"); |
return false; |
} |
function refreshGrid(arg) { |
$find("<%= RadAjaxManager.GetCurrent(this).ClientID %>").ajaxRequest("Rebind"); |
} |
</script> |
</telerik:RadCodeBlock> |
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPageMain" SelectedIndex="0"> |
<Tabs> |
<telerik:RadTab runat="server" PageViewID="PageViewTarefas" Selected="True" Text="Tarefas"> |
</telerik:RadTab> |
<telerik:RadTab runat="server" PageViewID="PageViewCategorias" Text="Categorias"> |
</telerik:RadTab> |
<telerik:RadTab runat="server" PageViewID="PageViewProjectos" Text="Projectos"> |
</telerik:RadTab> |
<telerik:RadTab runat="server" PageViewID="PageViewGrupos" Text="Grupos"> |
</telerik:RadTab> |
<telerik:RadTab runat="server" PageViewID="PageViewPesquisa" Text="Pesquisa"> |
</telerik:RadTab> |
</Tabs> |
</telerik:RadTabStrip> |
<telerik:RadMultiPage ID="RadMultiPageMain" runat="server" SelectedIndex="0"> |
<telerik:RadPageView ID="PageViewTarefas" runat="server" BackColor="White" Selected="True"><telerik:RadGrid |
ID="RadGridTarefas" runat="server" AllowPaging="True" |
AllowSorting="True" DataSourceID="SqlDataSourceTasks" |
GridLines="None" Skin="Hay" ShowStatusBar="True" |
AutoGenerateColumns="False" onitemdatabound="RadGridTarefas_ItemDataBound" |
PageSize="20" onitemcreated="RadGridTarefas_ItemCreated" |
ondatabound="RadGridTarefas_DataBound" ><HeaderContextMenu><CollapseAnimation Duration="200" Type="OutQuint" /></HeaderContextMenu><MasterTableView DataSourceID="SqlDataSourceTasks" CommandItemDisplay="Top" GridLines="Vertical" |
HierarchyDefaultExpanded="True" datakeynames="id_tarefas_trfs"><NoRecordsTemplate>Sem tarefas para visualizar...</NoRecordsTemplate><CommandItemSettings AddNewRecordText="Adicionar Tarefa" RefreshText="Actualizar Lista" /><Columns><telerik:GridTemplateColumn UniqueName="TmpltColTaskValidImg"><ItemTemplate><asp:Image ID="ImageTaskValidate" runat="server" ImageUrl="~/images/cog_error.png" /></ItemTemplate></telerik:GridTemplateColumn><telerik:GridTemplateColumn HeaderText="Opções" UniqueName="TmpltColTaskCmds" DataType="System.Int32" ForceExtractValue="Always"><ItemTemplate><asp:ImageButton |
ID="ImgCompleteButton" runat="server" BorderStyle="None" |
BorderWidth="0px" ImageUrl="~/images/tick.png" |
CommandName="TaskCommand" CommandArgument="CompleteTask" |
CausesValidation="False" /><asp:ImageButton ID="ImgEditButton" runat="server" BorderStyle="None" |
BorderWidth="0px" ImageUrl="~/images/pencil.png" CommandName="TaskCommand" CommandArgument="EditTask" /><asp:ImageButton ID="ImgDeleteButton" runat="server" BorderStyle="None" BorderWidth="0px" |
ImageUrl="~/images/cross.png" CommandArgument="DeleteTask" CommandName="TaskCommand" /><asp:ImageButton ID="ImgAttachButton" runat="server" BorderStyle="None" BorderWidth="0px" |
ImageUrl="~/images/attach.png" CommandName="TaskCommand" CommandArgument="TaskAnexos" /></ItemTemplate><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /><ItemStyle Wrap="False" /></telerik:GridTemplateColumn><telerik:GridBoundColumn DataField="nome_tarefas_trfs" HeaderText="Tarefa" |
UniqueName="ColTaskName"><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /></telerik:GridBoundColumn><telerik:GridTemplateColumn HeaderText="Prioridade" |
UniqueName="TmpltColPriorityImg"><ItemTemplate><asp:Image ID="ImagePriority" runat="server" /></ItemTemplate></telerik:GridTemplateColumn><telerik:GridBoundColumn DataField="nome_estados_trfs" HeaderText="Estado" |
UniqueName="ColTaskState"><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /></telerik:GridBoundColumn><telerik:GridDateTimeColumn DataField="prazo_tarefas_trfs" HeaderText="Prazo" |
UniqueName="ColTaskDeadline"><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /></telerik:GridDateTimeColumn><telerik:GridTemplateColumn HeaderText="Progresso" UniqueName="TmpltColProgBar"><ItemTemplate><telerik:RadSlider ID="RadSliderProgress" runat="server" Enabled="False" |
ItemType="Tick" ShowDecreaseHandle="False" ShowDragHandle="False" |
ShowIncreaseHandle="False" Skin="Telerik" Value="50" Width="100px" |
CausesValidation="False" LiveDrag="False" TrackMouseWheel="False"></telerik:RadSlider></ItemTemplate><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /></telerik:GridTemplateColumn><telerik:GridTemplateColumn HeaderText="Prog. Estimado" |
UniqueName="TmpltColEstProgBar"><ItemTemplate><telerik:RadSlider ID="RadSliderEstProgress" runat="server" Enabled="False" |
ShowDecreaseHandle="False" ShowDragHandle="False" ShowIncreaseHandle="False" |
Skin="Telerik" Width="100px" CausesValidation="False" LiveDrag="False"></telerik:RadSlider></ItemTemplate><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /></telerik:GridTemplateColumn><telerik:GridDateTimeColumn DataField="criado_tarefas_trfs" HeaderText="Criado" |
UniqueName="ColTaskCreated"><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /></telerik:GridDateTimeColumn><telerik:GridBoundColumn DataField="nome_utiliz" HeaderText="Autor" |
UniqueName="ColTaskCreator"><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="nome_apps_grupos" EmptyDataText="-" |
HeaderText="Grupo" UniqueName="ColTaskGroup"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="cod_apps_projectos" EmptyDataText="-" |
HeaderText="Projecto" UniqueName="ColTaskProject"></telerik:GridBoundColumn></Columns><EditFormSettings |
EditFormType="Template"></EditFormSettings><PagerStyle NextPagesToolTip="Próximas Páginas" |
NextPageToolTip="Próxima Página" |
PagerTextFormat="Mudar Página: {4} &nbsp;Apresentar página {0} of {1}, itens {2} to {3} of {5}." |
PrevPagesToolTip="Páginas Anteriores" PrevPageToolTip="Página Anterior" /><CommandItemTemplate><asp:LinkButton ID="LnkAddTask" runat="server"><img style="border: none 0px #000000" alt="Adicionar Tarefa" src="images/add.png" /> Adicionar Tarefa</asp:LinkButton><asp:LinkButton ID="LnkTaskHistory" runat="server"><img style="border: none 0px #000000" alt="Ver Historico" src="images/clock.png" /> Ver Historico</asp:LinkButton></CommandItemTemplate></MasterTableView><ClientSettings><Scrolling AllowScroll="True" UseStaticHeaders="True" /></ClientSettings><FilterMenu><CollapseAnimation Duration="200" Type="OutQuint" /></FilterMenu><StatusBarSettings LoadingText="Carregando..." ReadyText="Pronto" /><CommandItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /></telerik:RadGrid><asp:SqlDataSource ID="SqlDataSourceTasks" runat="server" |
ConnectionString="<%$ ConnectionStrings:DigitalGreenAppsConnectionString %>" |
SelectCommand="Proc_Tarefas_GetUserTasksByUserCode" |
SelectCommandType="StoredProcedure"><SelectParameters><asp:Parameter DefaultValue="01" Name="userCod" Type="String" /></SelectParameters></asp:SqlDataSource></telerik:RadPageView> |
<telerik:RadPageView ID="PageViewCategorias" runat="server" BackColor="White">categorias</telerik:RadPageView><telerik:RadPageView ID="PageViewGrupos" runat="server" BackColor="White" Height="16px">grupos</telerik:RadPageView><telerik:RadPageView ID="PageViewProjectos" runat="server" BackColor="White">projectos</telerik:RadPageView><telerik:RadPageView ID="PageViewPesquisa" runat="server" BackColor="White">pesquisa</telerik:RadPageView> |
</telerik:RadMultiPage> |
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista" |
Style="z-index: 7001" Behavior="Close" InitialBehavior="None" Modal="True" |
Overlay="True"> |
<Windows> |
<telerik:RadWindow Skin="Vista" ID="EditTaskDialog" runat="server" |
Title="User List Dialog" Height="500px" |
Width="500px" Left="" Modal="true" Overlay="True" |
ShowContentDuringLoad="False" Behavior="None" Behaviors="None" |
InitialBehavior="Pin" InitialBehaviors="Pin" /> |
</Windows> |
</telerik:RadWindowManager> |
</LoggedInTemplate> |
<AnonymousTemplate> |
Deve entrar na sua conta para viualizar as suas tarefas. |
</AnonymousTemplate> |
</asp:LoginView> |
</asp:Content> |
AND my Window Code
protected void LnkCancelChanges_Click(object sender, EventArgs e) |
{ |
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true); |
} |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditTaskForm.aspx.cs" Inherits="EditTaskForm" %> |
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title>Untitled Page</title> |
<style type="text/css"> |
.style2 |
{ |
width: 182px; |
} |
</style> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager runat="server"> |
</telerik:RadScriptManager> |
<div> |
<script type="text/javascript"> |
function CloseAndRebind(args) { |
GetRadWindow().Close(); |
GetRadWindow().BrowserWindow.refreshGrid(args); |
} |
function GetRadWindow() { |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well) |
return oWindow; |
} |
function CancelEdit() { |
GetRadWindow().Close(); |
} |
</script> |
<table align="center" style="width:61%;"> |
<tr> |
<td align="center" class="style2"> |
<asp:Label ID="LblTaskName" runat="server" Text="Nome da Tarefa"></asp:Label> |
</td> |
<td align="center" rowspan="2"> |
<telerik:RadCalendar ID="RadCalendar1" Runat="server" |
font-names="Arial,Verdana,Tahoma" forecolor="Black" |
style="border-color:#ececec" CultureInfo="Portuguese (Portugal)" |
Enabled="False" EnableMultiSelect="False" SelectedDate="" ViewSelectorText="x"> |
</telerik:RadCalendar> |
</td> |
</tr> |
<tr> |
<td align="center" class="style2"> |
<telerik:RadComboBox ID="RadComboBoxPriorities" Runat="server" |
LoadingMessage="Carregando..." Skin="Hay" Text="Prioridade"> |
<Items> |
<telerik:RadComboBoxItem runat="server" ImageUrl="~/images/exclamation.png" |
Text="Urgent" Value="6" /> |
<telerik:RadComboBoxItem runat="server" ImageUrl="~/images/flag_red.png" |
Text="Muito Alto" Value="5" /> |
<telerik:RadComboBoxItem runat="server" ImageUrl="~/images/flag_orange.png" |
Text="Alto" Value="4" /> |
<telerik:RadComboBoxItem runat="server" ImageUrl="~/images/flag_yellow.png" |
Text="Normal" Value="3" /> |
<telerik:RadComboBoxItem runat="server" ImageUrl="~/images/flag_green.png" |
Text="Baixo" Value="2" /> |
<telerik:RadComboBoxItem runat="server" ImageUrl="~/images/flag_blue.png" |
Text="Muito Baixo" Value="1" /> |
</Items> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</telerik:RadComboBox> |
<telerik:RadComboBox ID="RadComboBox1" Runat="server" |
DataSourceID="SqlDataSourceEstados" DataTextField="nome_estados_trfs" |
DataValueField="id_estados_trfs" LoadingMessage="Carregando..." Skin="Hay" |
Text="Estado"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</telerik:RadComboBox> |
<asp:SqlDataSource ID="SqlDataSourceEstados" runat="server" |
ConnectionString="<%$ ConnectionStrings:DigitalGreenAppsConnectionString %>" |
SelectCommand="SELECT [id_estados_trfs], [nome_estados_trfs] FROM [tarefas_estados]"> |
</asp:SqlDataSource> |
</td> |
</tr> |
<tr> |
<td class="style2"> |
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
<script type="text/javascript"> |
function OnClientValueChange(sender, args) |
{ |
var label1; |
if(sender.get_id() == $find("<%= RadSliderProgresso.ClientID %>").get_id()) |
{ |
label1 = $get("LblTaskProgress"); |
} |
label1.innerHTML = sender.get_selectionStart(); |
} |
</script> |
</telerik:RadCodeBlock> |
<telerik:RadSlider ID="RadSliderProgresso" runat="server" |
DecreaseText="Diminuir" DragText="Arrastar" IncreaseText="Aumentar" |
Skin="Telerik" onclientvaluechange="OnClientValueChange" Value="27"> |
</telerik:RadSlider> |
<asp:Label ID="LblTaskProgress" runat="server"></asp:Label>% |
</td> |
<td> |
</td> |
</tr> |
<tr> |
<td class="style2"> |
<asp:LinkButton ID="LnkAcceptChanges" runat="server"><img style="border: none 0px #000000" alt="Editar" src="images/pencil.png" /> Editar</asp:LinkButton> |
<asp:LinkButton ID="LnkCancelChanges" runat="server" onclick="LnkCancelChanges_Click"><img style="border: none 0px #000000" alt="Editar" src="images/cross.png" /> Cancel</asp:LinkButton> |
</td> |
<td> |
</td> |
</tr> |
</table> |
<br /> |
<br /> |
<br /> |
</div> |
</form> |
</body> |
</html> |
Any ideias?
Thanks in Advance