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

Lose GridButtonColumn attribute after opening a modal window

2 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leandro
Top achievements
Rank 1
Leandro asked on 22 Mar 2012, 08:52 PM
hi,

I have a GridButtonColumn type "ImageButton" where the ItemDataBound of the grid, I add an attribute "onclick" to him, in order to click it to open a modal window, only p /playback.
Well, the first by clicking the button, it works perfectly, the window opens correctly. Butwhen you close the window, and click the button again it will not fire the event "OnClick", so I think he loses the attribute adcionado earlier in the "ItemDataBound". Here is thecode used:
* Note: I tried to put the grid inside an UpdatePanel, but also without success. 

function Vizualizar_Baixa(indexRow) {
    alert("btn");
    var row = $find("<%=gridListagem.ClientID%>").get_masterTableView().get_dataItems()[indexRow];
    var id = row.getDataKeyValue("DFid_titulo_pagar");
    window.radopen("Vizualizar_Baixa.aspx?Pesquisar=" + id, "Vizualizar_Baixa");
}

<telerik:RadWindowManager id="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
    ReloadOnShow="true" runat="server" Skin="Outlook" EnableShadow="true" >
    <Windows>
        <telerik:RadWindow ID="Vizualizar_Baixa" runat="server" Behaviors="Pin,Close" Modal="true"
            Title="Consulta de Cadastros" Height="448px" Width="502px" />
    </Windows>
</telerik:RadWindowManager>
 
<telerik:RadGrid ID="gridListagem" runat="server" AllowPaging="True" PageSize="5"
    AutoGenerateColumns="False" CellSpacing="0" GridLines="None"
    AllowMultiRowSelection="True" Skin="Outlook"
    OnNeedDataSource="gridListagem_NeedDataSource"
    Width="950px">
    <ClientSettings EnableRowHoverStyle="true" >
        <Selecting AllowRowSelect="True" CellSelectionMode="None"/>
    </ClientSettings>
    <MasterTableView TableLayout="Auto" ClientDataKeyNames="DFid_titulo_pagar" >
        <CommandItemSettings ExportToPdfText="Export to PDF" />
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"
            Visible="True">
            <HeaderStyle Width="20px" />
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
            Visible="True">
            <HeaderStyle Width="20px" />
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFid_titulo_pagar"
                FilterControlAltText="Filter DFid_titulo_pagar column"
                HeaderText="DFid_titulo_pagar" UniqueName="DFid_titulo_pagar"
                Display="False">
            </telerik:GridBoundColumn>
            <telerik:GridClientSelectColumn UniqueName="DFcheck">
                <ItemStyle Width="25px" />
            </telerik:GridClientSelectColumn>
            <telerik:GridButtonColumn UniqueName="btnGrid" HeaderText="Baixa"
               ButtonType="ImageButton" ImageUrl="~/Icones/Grid.gif"
               HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle Width="25px" HorizontalAlign="Center" />
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFstatus"
                FilterControlAltText="Filter DFstatus column" HeaderText="Status"
                UniqueName="DFstatus" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="Status">
                <ItemTemplate>
                    <asp:Image ID="imgColumn" ImageUrl="" runat="server" />
                </ItemTemplate>
                <ItemStyle Width="25px" />
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFnumero_titulo"
                FilterControlAltText="Filter DFnumero_titulo column" HeaderText="N° Título"
                UniqueName="DFnumero_titulo">
                <ItemStyle Width="80px" />
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn AllowFiltering="False" DataField="DFdata_emissao"
                FilterControlAltText="Filter DFdata_emissao column" HeaderText="Emissão"
                UniqueName="DFdata_emissao" DataFormatString="{0:dd/MM/yyyy}">
                <ItemStyle Width="50px" />
            </telerik:GridDateTimeColumn>
            <telerik:GridDateTimeColumn AllowFiltering="False"
                DataField="DFdata_vencimento"
                FilterControlAltText="Filter DFdata_vencimento column" HeaderText="Vencimento"
                UniqueName="DFdata_vencimento" DataFormatString="{0:dd/MM/yyyy}">
                <ItemStyle Width="50px" />
            </telerik:GridDateTimeColumn>
            <telerik:GridNumericColumn AllowFiltering="False" AllowRounding="True"
                DataField="DFvalor" DecimalDigits="2"
                FilterControlAltText="Filter DFvalor column" HeaderText="Valor"
                UniqueName="DFvalor">
                <ItemStyle Width="100px" HorizontalAlign="Right" />
                <HeaderStyle HorizontalAlign="Right" />
            </telerik:GridNumericColumn>
            <telerik:GridNumericColumn AllowFiltering="False" AllowRounding="True"
                DataField="DFvalor_restante" DecimalDigits="2"
                FilterControlAltText="Filter DFvalor_restante column"
                HeaderText="Vlr. Restante" UniqueName="DFvalor_restante">
                <ItemStyle Width="100px" HorizontalAlign="Right" />
                <HeaderStyle HorizontalAlign="Right" />
            </telerik:GridNumericColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFcod_fornecedor"
                FilterControlAltText="Filter DFcod_fornecedor column"
                HeaderText="DFcod_fornecedor" UniqueName="DFcod_fornecedor" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFfornecedor"
                FilterControlAltText="Filter DFfornecedor column" HeaderText="Fornecedor"
                UniqueName="DFfornecedor">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False"
                DataField="DFcod_tipo_documento"
                FilterControlAltText="Filter DFcod_tipo_documento column"
                HeaderText="DFcod_tipo_documento" UniqueName="DFcod_tipo_documento"
                Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFtipo_documento"
                FilterControlAltText="Filter DFtipo_documento column"
                HeaderText="DFtipo_documento" UniqueName="DFtipo_documento" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFcnpj_cpf"
                FilterControlAltText="Filter DFcnpj_cpf column" HeaderText="DFcnpj_cpf"
                UniqueName="DFcnpj_cpf" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False"
                DataField="DFid_plano_conta_fornecedor"
                FilterControlAltText="Filter DFid_plano_conta_fornecedor column"
                HeaderText="DFid_plano_conta_fornecedor"
                UniqueName="DFid_plano_conta_fornecedor" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False"
                DataField="DFcod_plano_conta_fornecedor"
                FilterControlAltText="Filter DFcod_plano_conta_fornecedor column"
                HeaderText="DFcod_plano_conta_fornecedor"
                UniqueName="DFcod_plano_conta_fornecedor" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False"
                DataField="DFplano_conta_fornecedor"
                FilterControlAltText="Filter DFplano_conta_fornecedor column"
                HeaderText="DFplano_conta_fornecedor" UniqueName="DFplano_conta_fornecedor"
                Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFcod_plano_conta"
                FilterControlAltText="Filter DFcod_plano_conta column"
                HeaderText="DFcod_plano_conta" UniqueName="DFcod_plano_conta" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFplano_conta"
                FilterControlAltText="Filter DFplano_conta column" HeaderText="DFplano_conta"
                UniqueName="DFplano_conta" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False"
                FilterControlAltText="Filter DFhistorico column" HeaderText="DFhistorico"
                UniqueName="DFhistorico" Visible="False" DataField="DFhistorico">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFcontato"
                FilterControlAltText="Filter DFcontato column" HeaderText="DFcontato"
                UniqueName="DFcontato" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="DFtelefone"
                FilterControlAltText="Filter DFtelefone column" HeaderText="DFtelefone"
                UniqueName="DFtelefone" Visible="False">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>

Private Sub gridListagem_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gridListagem.ItemCreated
    If TypeOf e.Item Is GridDataItem Then
        Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim Button As System.Web.UI.WebControls.ImageButton = TryCast(dataItem("btnGrid").Controls(0), System.Web.UI.WebControls.ImageButton)
        Button.Attributes.Add("OnClick", "return Vizualizar_Baixa('" & dataItem.ItemIndex & "');")
        If dataItem("DFstatus").Text = "A" Then
            Dim imgColumn As Image = CType(dataItem("TempCol").FindControl("imgColumn"), Image)
            imgColumn.ImageUrl = "~/Icones/ok3_32_32.png"
        End If
    End If
End Sub

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Mar 2012, 07:34 AM
Hello Leandro,

I have made some modifications in your code and it is working as expected. In client side code for opening RadWindow, you can either give a unique windowname for each row in the grid or you can remove the windowname.
VB:
Protected Sub gridListagem_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim Button As System.Web.UI.WebControls.ImageButton = DirectCast(dataItem("btnGrid").Controls(0), System.Web.UI.WebControls.ImageButton)
        Button.Attributes.Add("OnClick", "Vizualizar_Baixa('" + dataItem.ItemIndex & "'); return false;")
    End If
End Sub
JS:
<script type="text/javascript">
    function Vizualizar_Baixa(indexRow) {
        alert("btn");
        var row = $find("<%=gridListagem.ClientID%>").get_masterTableView().get_dataItems()[indexRow];
        var id = row.getDataKeyValue("DFid_titulo_pagar");
      //  window.radopen("Test1.aspx?Pesquisar=" + id);
                         //   or
        window.radopen("Test1.aspx?Pesquisar=" + id, "Vizualizar_Baixa" + id);
    }
</script>

Thanks,
Princy.
0
Leandro
Top achievements
Rank 1
answered on 23 Mar 2012, 01:08 PM
Thanks for the feedback,

but breaking heads at night, I tried to change the name of radwindow before ("Vizualizar_Baixa") -> after("VizualizarBaixa"), and it worked perfectly ... seems to be some bug with the Id radwindow when it contains ("_") ... 

<script type="text/javascript">
    function Vizualizar_Baixa(indexRow) {
        alert("btn");
        var row = $find("<%=gridListagem.ClientID%>").get_masterTableView().get_dataItems()[indexRow];
        var id = row.getDataKeyValue("DFid_titulo_pagar");
        window.radopen("Vizualizar_Baixa.aspx?Pesquisar=" + id, "VizualizarBaixa");
    }
</script>

<telerik:RadWindowManager id="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
    ReloadOnShow="true" runat="server" Skin="Outlook" EnableShadow="true" >
    <Windows>
        <telerik:RadWindow ID="VizualizarBaixa" runat="server" Behaviors="Pin,Close" Modal="true"
            Title="Consulta de Cadastros" Height="448px" Width="502px" />
    </Windows>
</telerik:RadWindowManager>


I tried your example as well, but this way the "radopen" radwindow not know where to seek information as soon as the screen opens with the wrong format. 

Ty,

Leandro S. Mattos.
Tags
Grid
Asked by
Leandro
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Leandro
Top achievements
Rank 1
Share this question
or