[CLOSED] grid panel - exception on delete row

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] grid panel - exception on delete row

    In my gridrow I have ImageCommand and when click I need to delete row. My code is:

                        #{Store1}.remove(record);
                        #{Store1}.commitChanges();
                        #{GridPanel1}.getView().refresh();
    On click that part of code is ok, but after that I got exception:

    Microsoft JScript runtime error: Unable to get value of the property 'parentNode': object is null or undefined

    Can you help me with this, please?

    NOTE: Marking as closed. Please feel free to update the thread with a sample to reproduce the problem.
    Last edited by Daniil; Nov 02, 2011 at 4:08 PM. Reason: Marked as [CLOSED]. No requested info was provided.
  2. #2
    Hi,

    I was unable to reproduce the problem. Please provide your test case.

    Example

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                { 
                    new object[] { "test1", "test2", "test3" },
                    new object[] { "test4", "test5", "test6" },
                    new object[] { "test7", "test8", "test9" },
                };
                this.Store1.DataBind();
            }
        }
    </script>
    <!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>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test1" />
                                    <ext:RecordField Name="test2" />
                                    <ext:RecordField Name="test3" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test1" DataIndex="test1" />
                        <ext:Column Header="Test2" DataIndex="test2" />
                        <ext:Column Header="Test3" DataIndex="test3" />
                        <ext:ImageCommandColumn>
                            <Commands>
                                <ext:ImageCommand CommandName="delete" Icon="Delete" />
                            </Commands>
                        </ext:ImageCommandColumn>
                    </Columns>
                </ColumnModel>
                <Listeners>
                    <Command Handler="var store = this.getStore();
                                      store.remove(record);
                                      store.commitChanges();
                                      this.getView().refresh();" />
                </Listeners>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3
    All code is too complicated to post here ...

    This is my store:

                                    <ext:Store ID="Store1" runat="server">
                                        <Reader>
                                            <ext:JsonReader IDProperty="TR_ID">
                                                <Fields>
                                                    <ext:RecordField Name="TR_ID" Type="Int"></ext:RecordField>
                                                    <ext:RecordField Name="Trasat" Type="Int"></ext:RecordField>
                                                    <ext:RecordField Name="Partija"></ext:RecordField>
                                                    <ext:RecordField Name="TR_Naziv"></ext:RecordField>
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                    </ext:Store>
    when I Add new record to Store I do that in JS:

                function addToStore1() {
                    var myStore = #{Store1};
                    counter = counter - 1;
                    var tekuciRacun = { 
                        TR_ID: -1, 
                        Trasat: parseInt(#{TextFieldTrasat}.getValue()), 
                        Partija: getPartija10(#{TextFieldPartija}), 
                        TR_Naziv: #{TextFieldNazivRacuna_TR}.getValue() 
                    };
                    
                    var storeRecord = new myStore.recordType(tekuciRacun, counter); // create new record
                    myStore.add(storeRecord);
                    myStore.commitChanges();
                    
                    #{GridPanelTekuciRacuni}.getView().refresh();            
                }
    And after that if user need to delete added record with TR_ID = -1 he click to delete and i call this function:
                function DeleteTR(command, record) { 
                    if (record.data.TR_ID == -1) {
                        #{Store1}.remove(record);
                        #{Store1}.commitChanges();
                        #{GridPanelTekuciRacuni}.getView().refresh();
                    }
    else { 
    //... 
    }
                }
    (TR_ID is -1 is because user did not save record to database)
  4. #4
    Maybe some problem in TR_ID = -1? Because I put that is IDProperty in Store and for every new record tr_id is -1.
  5. #5
    Yes, there must be a unique id for every record.

    I guess the issue is not reproducible with a single new record, right?

    You could use the record's .isNew() method to check if record is a new one.
  6. #6
    No, probelm occurs when it is one single row.

    record.isNew() is 'undefined' for new record.


    in autogenerated code exception occurs here:

    var colIndex=this.grid.view.findCellIndex(target.parentNode.parentNode)
  7. #7
    Quote Originally Posted by boris View Post
    record.isNew() is 'undefined' for new record.
    Then please use the Store's .addRecord() method.
    myStore.addRecord({
        Trasat : parseInt(#{TextFieldTrasat}.getValue()),
        Partija : getPartija10(#{TextFieldPartija}),
        TR_Naziv : #{TextFieldNazivRacuna_TR}.getValue()
    };);
  8. #8
    I try but result is the same as when I use

    counter = counter - 1;
                    var tekuciRacun = { 
                        TR_ID: -1, 
                        Trasat: parseInt(#{TextFieldTrasat}.getValue()), 
                        Partija: getPartija10(#{TextFieldPartija}), 
                        TR_Naziv: #{TextFieldNazivRacuna_TR}.getValue() 
                    };
                    
                    var storeRecord = new myStore.recordType(tekuciRacun, counter); // create new record
                    myStore.add(storeRecord);
                    myStore.commitChanges();
  9. #9
    I can't see any difference comparing with the previous code.
  10. #10
    difference is :
    my code:
    myStore.add(storeRecord);
    your code:
    myStore.addRecord(...);
Page 1 of 2 12 LastLast

Similar Threads

  1. Ext.Net 2.0 Delete from Grid in C#
    By OSSAGHO in forum 2.x Help
    Replies: 0
    Last Post: Aug 08, 2012, 1:05 PM
  2. [CLOSED] Adding panels to a tab panel throws exception
    By RCM in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 09, 2012, 6:28 PM
  3. Replies: 4
    Last Post: Aug 09, 2010, 3:12 PM
  4. [CLOSED] Exception when grid contains no rows
    By alexp in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 18, 2009, 9:37 AM
  5. Problem with Delete Command and Grid Panel
    By jpmcm88 in forum 1.x Help
    Replies: 2
    Last Post: Jul 20, 2009, 1:02 PM

Tags for this Thread

Posting Permissions