Dec 30, 2014, 12:00 PM
[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 {}
A greeting !!
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]