Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem I have is when I call a Java Script function in the first row of the grid. #69

Open
HalconDivino opened this issue May 10, 2021 · 0 comments

Comments

@HalconDivino
Copy link

HalconDivino commented May 10, 2021

Hi how are things

I hope you can help me

The problem I have is when I call a Java Script function in the first row of the grid.

The problem only occurs in the first row of the grid, there is no problem with the other rows

The grid was developed with ItemTemplate with TextBox to capture data

for example I am capturing the data of an invoice in the first row of the grid

If I add the amount of the invoice plus the tax, it does not give me the total

I repeat it is only in the first line the problem

Is there something that can be done

GRIDVIEWE ASP NET


<asp:GridView 
            ID="grdContact" 
            runat="server" 
            AutoGenerateColumns="False" 
            DataKeyNames="FolioFactura" 
            Caption="FACTURAS QUE CONFORMAN LA RECEPCION" 
            CaptionAlign="Top" 
            Font-Size="X-Small" 
            OnRowDataBound="grdContact_RowDataBound" 
            CssClass="grdConsulta2">

            <AlternatingRowStyle BackColor="#F7F7F7" />
            <Columns>
                <asp:TemplateField Visible="true">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtPartida" 
                            runat="server" 
                            Text='<%# Bind("Partida") %>' 
                            TextMode="Number"   
                            Enabled="false"                            
                            Width="30px">

                        </asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField  HeaderText="Factura">
                     <ItemTemplate>
                          <asp:Button 
                               ID="btnPDF" 
                               runat="server" 
                               OnClick="btnPDF_Click"  
                               OnClientClick="SetTarget();"
                               Visible="true"
                               Text="PDF" 
                               Width="60px" 
                               BackColor="#FF0000" 
                               Font-Bold="True" 
                               ForeColor="White" />
                     </ItemTemplate>
                  </asp:TemplateField>

                <asp:TemplateField  HeaderText="Soporte">
                     <ItemTemplate>
                          <asp:Button 
                               ID="btnSoportePDF" 
                               runat="server" 
                               OnClick="btnSoportePDF_Click"  
                               OnClientClick="SetTarget();"
                               Visible="true"
                               Text="PDF" 
                               Width="60px" 
                               BackColor="#FF0000" 
                               Font-Bold="True" 
                               ForeColor="White" />
                     </ItemTemplate>
                  </asp:TemplateField>
              
                <asp:TemplateField HeaderText="Serie Factura">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtSerieFactura" 
                            runat="server" 
                            Text='<%# Bind("SerieFactura") %>' 
                            Width="100px">
                        </asp:TextBox>                        
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Folio Factura">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtFolioFactura" 
                            runat="server" 
                            Text='<%# Bind("FolioFactura") %>' 
                            Width="100px"
                            >
                        </asp:TextBox>                        
                        <ajaxToolkit:FilteredTextBoxExtender ID="txtFolioFactura_FilteredTextBoxExtender" runat="server" FilterType="Numbers" TargetControlID="txtFolioFactura" />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Serie O.C.">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtSerieOC" 
                            runat="server" 
                            Text='<%# Bind("SerieOC") %>' 
                            Width="100px"
                            >
                        </asp:TextBox>                        
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Folio O.C.">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtFolioOC" 
                            runat="server" 
                            Text='<%# Bind("FolioOC") %>' 
                            Width="100px"
                            >
                        </asp:TextBox>                        
                        <ajaxToolkit:FilteredTextBoxExtender ID="txtFolioOC_FilteredTextBoxExtender" runat="server" FilterType="Numbers" TargetControlID="txtFolioOC" />
                    </ItemTemplate>
                </asp:TemplateField>
               
                <asp:TemplateField HeaderText="SubTotal">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtSubTotal" 
                            runat="server" 
                            Text='<%# Bind("SubTotal") %>' 
                            style="text-align:right"
                            Width="100px" 
                            AutoPostBack="false" 
                            onchange="TotalRow(this);"
                            OnTextChanged="txtSubTotal_TextChanged">
                        </asp:TextBox>
                        
                        <ajaxToolkit:FilteredTextBoxExtender ID="txtSubTotal_FilteredTextBoxExtender" runat="server" FilterType="Custom, Numbers" TargetControlID="txtSubTotal" ValidChars="." />
                        
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="IVA">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtIVA" 
                            runat="server" 
                            Text='<%# Bind("IVA") %>' 
                            style="text-align:right"
                            Width="100px"
                            AutoPostBack="false"
                            onchange="TotalRow(this);"
                            OnTextChanged="txtIVA_TextChanged" >
                        </asp:TextBox>
                                                
                        <ajaxToolkit:FilteredTextBoxExtender ID="txtIVA_FilteredTextBoxExtender" runat="server" FilterType="Custom, Numbers" TargetControlID="txtIVA" ValidChars="." />
                        
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Total">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtTotal" 
                            runat="server" 
                            Text='<%# Bind("Total") %>' 
                            style="text-align:right"
                            Width="100px" 
                            Enabled="false"  >
                        </asp:TextBox>
                        
                        <ajaxToolkit:FilteredTextBoxExtender ID="txtTotal_FilteredTextBoxExtender" runat="server" FilterType="Custom, Numbers" TargetControlID="txtTotal" ValidChars="." />
                        
                    </ItemTemplate>
                </asp:TemplateField>


                <asp:TemplateField HeaderText="Folio N.C.">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtFolioNC" 
                            runat="server" 
                            Text='<%# Bind("FolioNC") %>' 
                            Width="100px"
                            >
                        </asp:TextBox>                        
                        <ajaxToolkit:FilteredTextBoxExtender ID="txtFolioNC_FilteredTextBoxExtender" runat="server" FilterType="Numbers" TargetControlID="txtFolioNC" />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Total NC">
                    <ItemTemplate>
                        <asp:TextBox 
                            ID="txtTotalNC" 
                            runat="server" 
                            Text='<%# Bind("TotalNC") %>' 
                            style="text-align:right"
                            Width="100px" 
                            Enabled="false"  >
                        </asp:TextBox>
                        
                        <ajaxToolkit:FilteredTextBoxExtender ID="txtTotalNC_FilteredTextBoxExtender" runat="server" FilterType="Custom, Numbers" TargetControlID="txtTotalNC" ValidChars="." />
                        
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Baja">
                    <ItemTemplate>
                        <asp:CheckBox ID="chkDelete" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#0000A9" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#000065" />
        </asp:GridView>


FUNCTION JAVA SCRIPT


            function TotalRow(obj)
            {
                var gridRow = obj.parentNode.parentNode;
                var rowIndex = gridRow.rowIndex;

                var grdvw = document.getElementById("<%=grdContact.ClientID %>");

                var SubTotal = grdvw.rows[rowIndex].cells[7].childNodes[1].value;
                var IVA = grdvw.rows[rowIndex].cells[8].childNodes[1].value;
                var Total = parseFloat(SubTotal) + parseFloat(IVA);

                grdvw.rows[rowIndex].cells[9].childNodes[1].value = Total.formatMoney(2, '.', ',');

               // alert("(" + Total + ")");
            }


CONFIG gridViewScroll 

    var gridViewScroll = null;

    window.onload = function () {
        gridViewScroll = new GridViewScroll({
            elementID: "<%=grdContact.ClientID%>",
            width: 1500,
            height: 620,
            freezeColumn: true,
            freezeFooter: false,
            freezeColumnCssClass: "GridViewScrollItemFreeze",
            freezeFooterCssClass: "GridViewScrollFooterFreeze",
            freezeHeaderRowCount: 1,
            freezeColumnCount: 1,
            onscroll: function (scrollTop, scrollLeft) {
                console.log(scrollTop + " - " + scrollLeft);
            }
        });

       // gridViewScroll.enhance();
    }


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant