[CLOSED] Update from 1.x to 2.x / #{store}.getAt(0).id trouble

  1. #1

    [CLOSED] Update from 1.x to 2.x / #{store}.getAt(0).id trouble

    Hello

    In Ext.Net 1.x I was retrieving the id of a record at a store during a onChange direct event of a paging toolbar (pagesize = 1). Since I switched to Version 2.x and I am creating everything in code behind with direct methods I have a little trouble. As in the demo: Instead of the ID value I get a strange string that incoporates the id value at the end. Any idea how I can get the simple ID value back?

    aspx:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form" runat="server">
    
            <ext:ResourceManager ID="ResourceManager" runat="server" />
    
            <!-- TAB DETAILS -->
            <ext:TabPanel runat="server" ID="TAB" MinTabWidth="100">
                <Items>
                    <ext:Panel ID="PANEL" runat="server" Title="Panel"><DirectEvents><Activate OnEvent="loadTab" /></DirectEvents></ext:Panel>
                </Items>
            </ext:TabPanel>
            
    
        </form>
    </body>
    </html>
    cs:
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Ext.Net;
    
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
                {
    
                }
        }
    
        protected void loadTab(object sender, DirectEventArgs e)
        {
            // create demo datatable
            DataTable dt = new DataTable();
    
            DataColumn dc = new DataColumn("ID");
            dt.Columns.Add(dc);
            dc = new DataColumn("VALUE");
            dt.Columns.Add(dc);
    
            DataRow dr = dt.NewRow();
            dr["ID"] = "1";
            dr["VALUE"] = "One";
    
            dt.Rows.Add(dr);
    
            dr = dt.NewRow();
            dr["ID"] = "2";
            dr["VALUE"] = "Two";
    
            dt.Rows.Add(dr);
    
            dr = dt.NewRow();
            dr["ID"] = "3";
            dr["VALUE"] = "Three";
    
            dt.Rows.Add(dr);
    
    
            // Build JOb Panel, add items and insert data
            Ext.Net.Panel panel = new Ext.Net.Panel
            {
                Title = "Panel",
                ID = "pnlPANEL",
                Height = 600,
                StyleSpec = "marginTop:10px",
                Items =
                    {
                        new Ext.Net.DataView {
                            ID = "dv",
                            Padding = 5,
                            ItemSelector = "div",
                            DisableSelection = true,
                            Store = {
                                new Ext.Net.Store {
                                    ID = "STORE_dv", PageSize = 1,
                                    Model = {
                                        new Ext.Net.Model {
                                            Fields = {
                                                new Ext.Net.ModelField { Name = "ID", Type = Ext.Net.ModelFieldType.String },
                                                new Ext.Net.ModelField { Name = "VALUE", Type = Ext.Net.ModelFieldType.String }
                                            },
                                            IDProperty = "ID"
                                        }
                                    },
                                    DataSource = dt,
                                    Sorters = { new Ext.Net.DataSorter { Property = "VALUE", Direction = Ext.Net.SortDirection.DESC } }
                                }
                            },
                            Tpl = new XTemplate {
                                Html = @"<tpl for=""."">
                                            <div>{ID}<br />{VALUE}
                                            </div>
                                        </tpl>"
                            }
                        }
                    },
                BottomBar = {
                    new PagingToolbar {
                        HideRefresh = true,
                        StoreID = "STORE_dv",
                        DisplayMsg = "",
                        Listeners = { Change = { Handler = "App.direct.onChange(((#{STORE_dv}.getCount() > 0) ? #{STORE_dv}.getAt(0).id : ''));" } }
                    }
                }
            };
    
            panel.AddTo(this.PANEL);
        }
    
        // On Change
        [DirectMethod]
        public void onChange(string ID)
        {
            X.Msg.Alert("Demo", ID).Show();
        }
    }
    Thank you very much!
    Last edited by Daniil; Sep 11, 2013 at 11:51 AM. Reason: [CLOSED]
  2. #2
    Hi @tMp,

    There are two possible solutions.

    1. Please set up IDProperty="ID" for the Model and use:
    #{STORE_dv}.getAt(0).getId()
    instead of
    #{STORE_dv}.getAt(0).id
    or

    2. Please use:
    #{STORE_dv}.getAt(0).get('ID')
    instead of
    #{STORE_dv}.getAt(0).id
  3. #3
    Perfect, thank you.

Similar Threads

  1. MVC Store Trouble
    By Doug.Morrow in forum 2.x Help
    Replies: 1
    Last Post: Aug 02, 2012, 10:17 PM
  2. [CLOSED] [1.0] Store and Paging trouble
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 08, 2011, 1:00 PM
  3. 'this.getAt(...).data' is null or not an object
    By Tbaseflug in forum 1.x Help
    Replies: 0
    Last Post: May 04, 2010, 1:50 PM
  4. Replies: 6
    Last Post: Aug 28, 2009, 12:19 PM
  5. [CLOSED] having trouble understanding ObjectDataSource Update
    By pkellner in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 16, 2008, 3:42 PM

Posting Permissions