[CLOSED] Store Error

  1. #1

    [CLOSED] Store Error

    Good.

    In the example SimpleTask I added a command that displays a window. This window has within a grid, but no data is refreshed. I show the code.

    The window opens correctly when clicking the command, the grid is created, but does not call LogGrid_RefreshData. Produce an error status code 200 OK status text {}

    
         /// <summary>
            /// 
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            void Command_Event(object sender, DirectEventArgs e)
            {
                string command = e.ExtraParams["command"];
                int taskId;
                int categoryID;
    
                switch (command)
                {
                    case "seguimiento":
                        new TaskWindowLog(int.Parse(e.ExtraParams["taskId"])).Render(this.Page.Form.ClientID, RenderMode.RenderTo);
                        break;
                }
            }
    UI
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Ext.Net;
    using Task.Tasks.Classes.Model;
    
    namespace Task.Tasks.Classes
    {
        public partial class TaskWindowLog : Window
        {
            /// <summary>
            /// 
            /// </summary>
            private GridPanel gridPanel;
    
            /// <summary>
            /// 
            /// </summary>
            private Store store;
    
            /// <summary>
            /// 
            /// </summary>
            public TaskWindowLog()
            {
                this.Width = 800;
                this.Height = 450;
                this.Resizable = false;
                this.Layout = "Border";
                this.CloseAction = CloseAction.Destroy;
    
                this.Buttons.Add(new Button("Cerrar"));
    
                this.BuildGrid();
                this.BuildStore();
                this.BuildColumnModel();
            }
    
            /// <summary>
            /// 
            /// </summary>
            private void BuildGrid()
            {
    
                this.gridPanel = new GridPanel
                {
                    Region = Ext.Net.Region.Center
                };
    
                this.gridPanel.SelectionModel.Add(new RowSelectionModel
                {
                });
    
    
                this.gridPanel.BottomBar.Add(new PagingToolbar
                {
    
                });
    
                this.Items.Add(this.gridPanel);
            }
    
            /// <summary>
            /// 
            /// </summary>
            private void BuildColumnModel()
            {
                GridHeaderContainer cm = this.gridPanel.ColumnModel;
    
                cm.Columns.Add(new Column
                {
                    Text = "Operaci?n",
                    Flex = 1,
                    Sortable = true,
                    DataIndex = "Title"
                });
    
                cm.Columns.Add(new Column
                {
                    Text = "Creador",
                    Width = 120,
                    Sortable = true,
                    DataIndex = "IDUSRCreate",
                    Renderer = new Renderer(TaskWindowLog.SCOPE + ".renderCreate")
                });
    
                cm.Columns.Add(new DateColumn
                {
                    Text = "Fecha",
                    Format = "dd/MM/yyyy HH:mm",
                    Width = 100,
                    Sortable = true,
                    DataIndex = "DateAdded"
                });
            }
    
            /// <summary>
            /// 
            /// </summary>
            private void BuildStore()
            {
                this.store = new Store
                {
                    AutoLoad = true,
                    PageSize = 10,
                    Model =
                     {
                         new Ext.Net.Model
                         {
                             IDProperty = "AlertID",
                             Fields =
                             {
                                 new ModelField("AlertID", ModelFieldType.Int),
                                 new ModelField("TaskID", ModelFieldType.Int),
                                 new ModelField
                                 {
                                     Name = "Tarea",
                                     ServerMapping = "ag_Task.Title"
                                 },
                                 new ModelField("IDUSR", ModelFieldType.Int),
                                 new ModelField("IDUSRCreate", ModelFieldType.Int),
                                 new ModelField
                                 {
                                     Name = "UserName",
                                     ServerMapping = "USRUSER.TxNombre"
                                 },
                                     new ModelField
                                 {
                                     Name = "UserApelli1",
                                     ServerMapping = "USRUSER.TxApelli1"
                                 },
                                 new ModelField
                                 {
                                     Name = "UserNameC",
                                     ServerMapping = "USRUSER1.TxNombre"
                                 },
                                     new ModelField
                                 {
                                     Name = "UserApelli1C",
                                     ServerMapping = "USRUSER1.TxApelli1"
                                 },
                                 new ModelField("Title"),
                                 new ModelField("Description"),
                                 new ModelField("DateAdded", ModelFieldType.Date)
                             }
                         }
                     },
                    Sorters = 
                     {
                        new DataSorter()
                        {
                            Property = "DateAdded",
                            Direction = SortDirection.DESC
                        }
                     },
                    GroupField = "DateAdded",
                    Proxy =
                     {
                         new PageProxy()
                     }
                };
    
                this.gridPanel.Store.Add(this.store);
            }
    
        }
    }
    Logic

    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Task.Tasks.Classes.Model;
    
    using Ext.Net.Utilities;
    using Ext.Net;
    using Task.Class;
    
    namespace Task.Tasks.Classes
    {
        public partial class TaskWindowLog
        {
            /// <summary>
            /// 
            /// </summary>
            private SimpleTasksDataContext DBContext
            {
                get
                {
                    SimpleTasksDataContext ctx = new SimpleTasksDataContext();
                    ctx.DeferredLoadingEnabled = true;
    
                    return ctx;
                }
            }
    
            /// <summary>
            /// 
            /// </summary>
            public const string SCOPE = "SimpleTasks.TaskWindow";
    
            /// <summary>
            /// 
            /// </summary>
            private int taskId;
    
            /// <summary>
            /// 
            /// </summary>
            /// <param name="taskId"></param>
            public TaskWindowLog(int taskId): this()
            {
                this.ID = "TaskWindowLog_" + taskId;
                this.taskId = taskId;
    
                SimpleTasksDataContext ctx = this.DBContext;
    
                ag_Task task = (from t in ctx.ag_Task where t.TaskID == taskId select t).FirstOrDefault();
    
                if (task != null)
                {
                    this.Title = "Tarea - " + task.Title.Ellipsis(40);
    
                    this.CustomConfig.Add(new ConfigItem("taskId", taskId.ToString(), ParameterMode.Raw));
    
                    this.InitLogic();
                }
                else
                {
                    this.Title = "Nueva Tarea";
    
                    this.CustomConfig.Add(new ConfigItem("taskId", taskId.ToString(), ParameterMode.Raw));
    
                    this.InitLogic();
                }
            }
    
            /// <summary>
            /// 
            /// </summary>
            private void InitLogic()
            {
                this.Buttons[0].Handler = new JFunction(this.ID + ".close();").ToScript();
    
                this.store.ReadData += LogGrid_RefreshData;
    
                Store store = this.store;
                store.Parameters.Add(new StoreParameter("taskID", taskId.ToString(), ParameterMode.Value));
            }
    
            /// <summary>
            /// 
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            void LogGrid_RefreshData(object sender, StoreReadDataEventArgs e)
            {
                int taskID = 0;
    
                if (!int.TryParse(e.Parameters["taskID"], out taskID))
                {
                    Ext.Net.X.Msg.Show(new MessageBoxConfig
                    {
                        Title = "Error",
                        Message = "Tarea sin informaci?n",
                        Icon = MessageBox.Icon.ERROR,
                        Buttons = MessageBox.Button.OK
                    });
    
                    return;
                }
    
            }
        }
    }
    Any ideas ?? I am blocked.

    A greeting !!
    Last edited by Daniil; Jan 16, 2015 at 8:32 AM. Reason: [CLOSED]
  2. #2
    Hi @threewonders,

    This is a regular DirectEvent.
    this.store.ReadData += LogGrid_RefreshData;
    I mean a Store's ReadData event.

    Any Ext.NET DirectEvent requires a control instance on server side. Otherwise, a DirectEvent cannot be executed and it throws an Exception like you see. You create the Store in one request, but the ReadData DirectEvent is another request. The Store is not recreated automatically.

    There is no any simple way to overcome, but there is a few alternative ways to go.

    1. Recreate the Store (actually, you might need to recreate the entire TaskWindowLog control). Here is some example with recreating controls.
    http://forums.ext.net/showthread.php...l=1#post109918

    or

    2. Use a PageProxy with a DirectFn.
    https://examples2.ext.net/#/GridPane..._DirectMethod/

    or

    3. Use an AjaxProxy and refer to an HttpHandler or a WebService.
    https://examples2.ext.net/#/GridPane...rting/Handler/

    Personally, I would definitely prefer the option #2 or #3.

Similar Threads

  1. [CLOSED] JavaScript Error when adding Store to a Bin
    By CarlosG in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 05, 2014, 3:19 AM
  2. Replies: 1
    Last Post: Dec 14, 2011, 8:17 PM
  3. [CLOSED] Error with store
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 08, 2010, 4:18 AM
  4. [CLOSED] Store error with HttpProxy
    By GmServizi in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Oct 28, 2009, 7:04 AM
  5. Error dynamic store
    By jortega in forum 1.x Help
    Replies: 0
    Last Post: Apr 24, 2009, 8:23 AM

Posting Permissions