[CLOSED] negative Ids in table are considered CREATE not UPDATE

  1. #1

    [CLOSED] negative Ids in table are considered CREATE not UPDATE

    v3.2.1
    I load a grid and mark the IDProperty properly in the model. Then when i load the grid with data.... i use a negative value for the IDProperty field. When i submit the grid as a batch submit, it assumes negative values are CREATED (instead of UPDATED). in v1,7, only values==0 are CREATED and negative values are UPDATED.

    price is editable

    This is a serious issue and should be reverted!

    also, it converts all negative values to zero.

    Thanks,
    /Z

    markup
    <%@ Page Language="C#" %>
    
    
    <script runat="server">
        private object[] TestData
        {
            get
            {
                DateTime now = DateTime.Now;
    
    
                return new object[]
                {
                    new object[] {-1, "3m Co", "1/1 12:00am", "Up", 71.72, 0.02, 0.03, now },
                    new object[] {-2, "Alcoa Inc", "1/1 12:00am", "Up", 29.01, 0.42, 1.47, now },
                    new object[] {-3, "Altria Group Inc", "1/1 12:00am", "Up", 83.81, 0.28, 0.34, now }
                };
            }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.TestData;
            }
        }
    </script>
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head id="Head1" runat="server">
        <title>Cell to Cell Drag and Drop - Ext.NET Examples</title>    
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    
            <h1>Drag and Drop from Cell to Cell within the same GridView</h1>
            <p>This illustrates how a custom plugin can enable a cell to cell drag and drop operation within the same GridView.</p>
            <p>This example only allows a drag and drop operation for cells with the same data type, although that is configurable. The custom plugin allows for other configs, please see the comments in the source.</p>
            
            <ext:GridPanel ID="GridPanel1" 
                runat="server"                         
                Width="800"
                Height="400">
                <Store>
                    <ext:Store 
                        ID="Store1" 
                        runat="server">
                        <Model>
                            <ext:Model ID="Model1" runat="server" IDProperty="id">
                                <Fields>
                                    <ext:ModelField Name="id" Type="Int" />
                                    <ext:ModelField Name="company" Type="String" />
                                    <ext:ModelField Name="firstChange" Type="Date" DateFormat="M/d hh:mmtt" />
                                    <ext:ModelField Name="stock" />
                                    <ext:ModelField Name="price" Type="Float" />
                                    <ext:ModelField Name="change" Type="Float" />
                                    <ext:ModelField Name="pctChange" Type="Float" />
                                    <ext:ModelField Name="lastChange" Type="Date" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Text="Company" DataIndex="company" Width="160" />
                        <ext:DateColumn ID="DateColumn1" runat="server" Text="First Updated" DataIndex="firstChange" Width="235" />
                        <ext:Column ID="Column2" runat="server" Text="Price" DataIndex="price" Width="75" >
                            <Editor>
                                <ext:TextField ID="TextField2" runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column ID="Column4" runat="server" Text="Change" DataIndex="change" Width="75" />
                        <ext:Column ID="Column5" runat="server" Text="% Change" DataIndex="pctChange" Width="75" />
                        <ext:DateColumn ID="DateColumn2" runat="server" Text="Last Updated" DataIndex="lastChange" Width="235" />
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:CellEditing ID="CellEditing1" ClicksToEdit="1" runat="server" />
                </Plugins>
                <BottomBar>
                    <ext:Toolbar ID="ToolbarTimecardButtons" runat="server">
                        <Items>
                            <ext:Button runat="server" Text="Save" Icon="Disk">
                                <DirectEvents> 
                                    <Click 
                                        Url="/test" 
                                        Timeout="60000"
                                        CleanRequest="true" 
                                        Method="POST">
                                        <EventMask MinDelay="250" />
                                        <ExtraParams> 
                                            <ext:Parameter Name="data" Value="#{Store1}.getChangedData()" Mode="Raw" Encode="true" />
                                        </ExtraParams> 
                                    </Click>    
                                </DirectEvents>                                                     
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:GridPanel>        
        </form>
    </body>
    </html>
    controller
            public DirectResult test(FormCollection values)
            {
                StoreDataHandler dataHandler = new StoreDataHandler(values["data"]);
                ChangeRecords<object> data = dataHandler.BatchObjectData<object>();
                //data.Update is 0
                //data.Create is >0
            }
    Last edited by Daniil; Sep 17, 2015 at 3:39 PM. Reason: [CLOSED]
  2. #2
    Hi @Z,

    I could reproduced it. My steps are:

    1. Run your code
    2. Edit a couple of records
    3. Click the Save record
    4. I see two records in the Updated collection and nothing in the Created one.

    Also the negative ids are not converted to zeros.

    I am testing with the latest Ext.NET from SVN trunk.
  3. #3
    I think this was caused by an old fix I put in for v1 problem. See this posting

    http://forums.ext.net/showthread.php...record-data-id

    Can close
    /Z

Similar Threads

  1. update table content
    By lesiano in forum 2.x Help
    Replies: 2
    Last Post: Jul 29, 2014, 6:50 AM
  2. Create Html Table Dynamically
    By DanielU in forum 1.x Help
    Replies: 2
    Last Post: Dec 15, 2012, 4:15 PM
  3. Replies: 0
    Last Post: Aug 09, 2012, 5:37 AM
  4. [CLOSED] Editor Can create table ???
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 11, 2012, 1:49 PM
  5. UpDate Table with SqlDataSource
    By yairoman in forum 1.x Help
    Replies: 0
    Last Post: Jan 25, 2010, 10:54 PM

Posting Permissions