May 07, 2021, 1:30 PM
[CLOSED] CellEditingPlugin Edit event over CheckColumn
Hello!
I get a different behavior handling CellEditingPlugin's Edit DirectEvent if I edit a TextColumn or a CheckColumn.
Here is my scenario:
CheckColumn.cshtml
In my main-project.
Could you please give me some advice?
Thank you very much!
I get a different behavior handling CellEditingPlugin's Edit DirectEvent if I edit a TextColumn or a CheckColumn.
Here is my scenario:
CheckColumn.cshtml
@page "{handler?}"
@model ExtCookbook.Pages.CheckColumnModel
@{
ViewData["Title"] = "GridPanel CheckColumn";
}
<ext-section target="Main">
<ext-panel id="MainContainer" region="Center" layout="Border" scrollable="true" paddingAsString="0">
<items>
<ext-gridPanel model="@Model.myGrid" />
</items>
</ext-panel>
</ext-section>
CheckColumn.cshtml.csusing System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ext.Net;
using Ext.Net.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ExtCookbook.Pages
{
public class CheckColumnModel : PageModel
{
public GridPanel myGrid { get; set; }
public void OnGet()
{
myGrid = gridPanel();
}
private GridPanel gridPanel()
{
//trovo le date da / a del range
var fromDate = DateTime.Now.Date;
var toDate = DateTime.Now.Date.AddDays(5);
var grd = new GridPanel()
{
Id = "myGrid",
Title = "Check column",
Anchor = "100%",
Region = RegionType.Center
};
var df = new List<DataField>
{
new DataField() { Name = "description", Type = DataFieldType.String }
};
var c = new List<Column>()
{
new Column() { DataIndex = "description", Text = "Description", Width = 250, Locked = true, Editor = new TextField() },
};
for (int i = 0; fromDate.AddDays(i) <= toDate; i++)
{
df.Add(new DataField() { Name = fromDate.AddDays(i).ToString("yyyyMMdd"), Type = DataFieldType.Bool });
c.Add(new CheckColumn()
{
DataIndex = fromDate.AddDays(i).ToString("yyyyMMdd"),
Text = fromDate.AddDays(i).ToString("ddd d MMM"),
Width = 120,
CustomConfig = new JsObject
{
{ "editable", true }
}
});
}
var m = new Model()
{
IdProperty = "description",
Fields = df
};
// Store
var s = new Store();
s.ModelValue = m;
// Data
var tbl = new List<object>();
for (int r = 0; r < 5; r++)
{
var row = new Dictionary<string, object>
{
{ "description", $"Row #{r}" }
};
for (int i = 0; fromDate.AddDays(i) <= toDate; i++)
{
row.Add(fromDate.AddDays(i).ToString("yyyyMMdd"), false);
}
tbl.Add(row);
}
s.Data = tbl;
// Add to grid
grd.Store = s;
grd.Columns = c;
// Editing
var p = new CellEditingPlugin();
p.DirectEvents.Edit.Method = HttpMethod.POST;
p.DirectEvents.Edit.Url = $"?handler=CellEdit";
p.DirectEvents.Edit.ExtraParams.Add(new DirectEventParameter() { Key = "senderId", Value = grd.Id, Mode = ParameterMode.Value });
p.DirectEvents.Edit.ExtraParams.Add(new DirectEventParameter() { Key = "row", Value = "App." + grd.Id + ".selection ? App." + grd.Id + ".selection.data : null", Mode = ParameterMode.Raw });
p.DirectEvents.Edit.ExtraParams.Add(new DirectEventParameter() { Key = "e", Value = "e", Mode = ParameterMode.Raw });
grd.Plugins = new List<AbstractPlugin>();
((List<AbstractPlugin>)grd.Plugins).Add(p);
return grd;
}
public IActionResult OnPostCellEdit(JsObject jObj)
{
this.X().Toast("row count: " + jObj.GetValueOrDefault("row").Count);
this.X().Toast("e count: " + jObj.GetValueOrDefault("e").Count);
return this.Direct();
}
}
}
In this Repro-project.- When I check a field nothing happens.
- When I change a text field the event has thrown.
e
variable is empty.In my main-project.
- When I check a field event has fired
e
has fields (even ife.row
is empty there are other fields, likee.originaValue
and it is the same of the ext.js code). - When I change a text field the event has thrown
e
is empty, but other extraparmams are good androw
has the new value. - If I check the box the grid row won't be selected, and it causes the
row
to be empty.
Could you please give me some advice?
Thank you very much!