[CLOSED] Store issue in new version

  1. #1

    [CLOSED] Store issue in new version

    Hi,

    Recently I converted to new ext.net version from 2.1 to 2.5. but I got one issue while using getChangedData() method on store.

    Here I have attached minified sample.

    First click on "Add In Grid" button to add new record and then click on "Save" button, on save button code, I am not getting added records count, can you suggest me what is wrong with this?


    <%@ Page Title="Home Page" Language="C#" %>
    
    <ext:ResourceManager ID="Res1" runat="server"></ext:ResourceManager>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!X.IsAjaxRequest)
                {
                    List<BloodGroup> lstBloodGroup = new List<BloodGroup>();
                    this.StoreBloodGroup.DataSource = lstBloodGroup.ToList();
                    this.StoreBloodGroup.DataBind();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    
        protected void Save_Click(object sender, DirectEventArgs e)
        {
            try
            {
                ChangeRecords<BloodGroup> bloodgroups = new StoreDataHandler(e.ExtraParams["BloodGroupData"]).BatchObjectData<BloodGroup>();
    
                if (bloodgroups.Deleted.Count > 0 || bloodgroups.Created.Count > 0 || bloodgroups.Updated.Count > 0)
                {
                    string message = "";
                    message = "Inserted Records : " + bloodgroups.Created.Count.ToString();
                    message += "Updated Records : " + bloodgroups.Updated.Count.ToString();
                    message += "Deleted Records : " + bloodgroups.Deleted.Count.ToString();
                    new MessageBox().Show(new MessageBoxConfig()
                    {
                        Title = " ",
                        Message = message,
                        Buttons = MessageBox.Button.OK,
                    });
                }
                else
                {
                    new MessageBox().Show(new MessageBoxConfig()
                    {
                        Title = " ",
                        Message = "No Records to be saved!",
                        Buttons = MessageBox.Button.OK,
                    });
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    
        protected void btnAddInGrid_Click(object sender, DirectEventArgs e)
        {
            try
            {
                BloodGroup bg = new BloodGroup();
                bg.BloodGrpName = "abc";
                this.StoreBloodGroup.Add(bg);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    
        public class BloodGroup
        {
            public long BloodGrpID { get; set; }
            public string BloodGrpName { get; set; }
        }
    </script>
    <ext:GridPanel runat="server" ID="GridBloodGroup"
        IDMode="Static" ColumnLines="true" Height="600">
        <Store>
            <ext:Store runat="server" ID="StoreBloodGroup" IDMode="Static">
                <Model>
                    <ext:Model runat="server" ID="ModelBloodGroup" IDProperty="BloodGrpID">
                        <Fields>
                            <ext:ModelField Name="BloodGrpID" Type="Int" />
                            <ext:ModelField Name="BloodGrpName" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
        </Store>
        <ColumnModel>
            <Columns>
                <ext:Column ID="Column1" runat="server" DataIndex="BloodGrpID" Text="Blood Group ID" Sortable="true" Width="110">
                    <Editor>
                        <ext:TextField ID="TextField1" runat="server" AllowBlank="false">
                        </ext:TextField>
                    </Editor>
                </ext:Column>
                <ext:Column ID="colBloodGroupName" runat="server" DataIndex="BloodGrpName" Text="Blood Group Name" Sortable="true" Hideable="true" Width="110">
                    <Editor>
                        <ext:TextField ID="txtBloodGroupName" runat="server" AllowBlank="false">
                        </ext:TextField>
                    </Editor>
                </ext:Column>
            </Columns>
        </ColumnModel>
        <Plugins>
            <ext:CellEditing ID="CellEditing1" runat="server" ClicksToEdit="1">
            </ext:CellEditing>
        </Plugins>
        <Buttons>
            <ext:Button ID="btnAddInGrid" runat="server" IDMode="Static" Icon="Add" Text="Add In Grid">
                <DirectEvents>
                    <Click OnEvent="btnAddInGrid_Click" />
                </DirectEvents>
            </ext:Button>
    
            <ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
                <DirectEvents>
                    <Click OnEvent="Save_Click">
                        <ExtraParams>
                            <ext:Parameter Name="BloodGroupData" Value="App.StoreBloodGroup.getChangedData({skipIdForNewRecords : true})" Mode="Raw" Encode="true" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </Buttons>
    </ext:GridPanel>
    Last edited by Daniil; Jul 12, 2014 at 9:05 AM. Reason: [CLOSED]
  2. #2
    Hi @shaileshsakaria,

    This
    BloodGroup bg = new BloodGroup();
    creates an instance of the BloodGroup type where BloodGrpID is 0 by default.

    That zero goes to a client side:
    {script:"App.StoreBloodGroup.add({\"BloodGrpID\":0,\"BloodGrpName\":\"abc\"});"}
    It means that you have explicitly set up the IDProperty ModelField. Such a record is not considered as a new one. It is considered as already saved. Therefore it doesn't go to .getChangedData().

    Your scenario might work with a Nullable long.
    public long? BloodGrpID { get; set; }
  3. #3
    Thanks for your reply.

    By doing Nullable long its working but I can't do nullable to primary key as I have binded Entity framework classes directly to Store in almost all pages (more than 300 pages). In old version (2.1) the same thing was working, can you tell me easy solution?


    Thanks
  4. #4
    In old version (2.1) the same thing was working
    I would say it was a bug.

    can you tell me easy solution?
    Is that acceptable?
    this.StoreBloodGroup.Add(new
    {
        BloodGrpName = "abc"
    });
    Also you might need to use a UseNull option.
    <ext:ModelField Name="BloodGrpID" Type="Int" UseNull="true" />
    Last edited by Daniil; Jul 08, 2014 at 4:12 PM.
  5. #5
    Thanks for reply.

    Yes its worked.

Similar Threads

  1. Generic Plugin issue in latest version
    By kavitha in forum 2.x Help
    Replies: 1
    Last Post: Oct 03, 2013, 11:07 PM
  2. [CLOSED] Calender View in Razor - Version issue
    By MTSI in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 05, 2012, 9:28 AM
  3. 1.3 version issue
    By emover in forum 1.x Help
    Replies: 0
    Last Post: May 05, 2012, 5:46 PM
  4. [CLOSED] Issue with Check Box Rendering in IE7 - Coolite Version 0.8.3
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Feb 09, 2011, 1:22 PM
  5. [CLOSED] Issue with Dynamic Controlsl creation in Tab Panels (Version: 0.8.3)
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 25, 2010, 6:29 PM

Posting Permissions