Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
Add new row into WebDataGrid using Javascript deleteing the first row
posted

Hi,

I have a strange issue, I have a bottom that adds a new records into WebDataGrid using Java script, the issue that after I add the first new row, and trying to add second row it deletes the first row , after that it works fin, only with the first row at the first time! also the counting starts with 0, so when i insert the row, it would give me 0 under No. and then when I add a new row it deletes the 0 row and add the 1 No, and it goes normally, can you please help?

 function AddDocCheckList() {
            var grid = $find('<%= chdocs_web.ClientID %>');
            var rowscount = grid.get_rows().get_length() +1  ;
            var doctype = $find('<%= chdoctype_drop.ClientID %>');
            var chyes = $find('<%= chyes_drop.ClientID %>');
            var chComments = $find('<%= chcomments_txt.ClientID %>');
            var rows = grid.get_rows();
            var rr = new Array(rowscount, doctype.get_selectedItem().get_value(), chyes.get_selectedItem().get_value(), chComments.get_value())
            grid.get_rows().add(rr);
         }

<igtxt:WebImageButton ID="checkinsert_btn" runat="server" Text="Insert Document" AutoSubmit="false">
<ClientSideEvents Click="AddDocCheckList" />
<Appearance>
<Image Url="./Res/Apps-Dialog-Add-icon.png" />
</Appearance>
</igtxt:WebImageButton>

 <ig:WebDataGrid ID="chdocs_web" runat="server" AutoGenerateColumns="False" DataSourceID="ComDocchecklistDS" Height="350px" Width="561px" EnableAjax="False">
                                    <Columns>
                                        <ig:BoundDataField DataFieldName="orderno" Key="orderno" Width="35px">
                                            <Header Text="No.">
                                            </Header>
                                        </ig:BoundDataField>
                                        <ig:BoundDataField DataFieldName="doctype" Key="doctype">
                                            <Header Text="Document Received">
                                            </Header>
                                        </ig:BoundDataField>
                                        <ig:BoundDataField DataFieldName="yesno" Key="yesno" Width="60px">
                                            <Header Text="Yes/No">
                                            </Header>
                                        </ig:BoundDataField>
                                        <ig:BoundDataField DataFieldName="comments" Key="comments">
                                            <Header Text="Comments">
                                            </Header>
                                        </ig:BoundDataField>
                                    </Columns>
                                    <Behaviors>
                                        <ig:EditingCore BatchUpdating="True">
                                        </ig:EditingCore>
                                    </Behaviors>
                                </ig:WebDataGrid>

<igtxt:WebImageButton ID="checkinsert_btn" runat="server" Text="Insert Document" AutoSubmit="false">
<ClientSideEvents Click="AddDocCheckList" />
<Appearance>
<Image Url="./Res/Apps-Dialog-Add-icon.png" />
</Appearance>
</igtxt:WebImageButton>

First attempt to insert a row

second attempt and afterwards, you can see it deleted the 0 No which was inserted in the first attempt

Parents
  • 1620
    Offline posted

    Hello, 

    I have created a small sample trying to reproduce the described behavior. I am using WebDataGrid with version 22.1. On my side everything works as expected and I am able to add rows to the empty grid on the client-side without any issues, the rows are added starting from index 0 and no rows are deleted after their addition. I have tested the sample in Edge and Chrome. 

    Attached you will find my sample for your reference. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve, please feel free to modify it and send it back to me along with steps to reproduce. Alternatively, please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application and attach it in this case.

    Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior. 

    Thank you for your cooperation.  

    Looking forward to hearing from you. 

    Regards,
    Ivan Kitanov

    AddRowToEmptyGrid.zip

Reply Children