Asp.net mvc 在syncfusion中为网格创建数据库中没有记录的列;假栏;MVC
我正在从查询多个表的视图生成网格。我需要添加一列,该列将由用户通过输入金额进行编辑,以便该行可以保存为两个表中的新记录。这就是为什么该列没有真正在数据库中生成,因为实际上没有包含该金额的记录Asp.net mvc 在syncfusion中为网格创建数据库中没有记录的列;假栏;MVC,asp.net-mvc,blazor,syncfusion,Asp.net Mvc,Blazor,Syncfusion,我正在从查询多个表的视图生成网格。我需要添加一列,该列将由用户通过输入金额进行编辑,以便该行可以保存为两个表中的新记录。这就是为什么该列没有真正在数据库中生成,因为实际上没有包含该金额的记录 @(Html.EJ().Grid<object>("ITEMS_PRESUPUESTOGrid") .Datasource(ds => ds.URL("GetOrderData_VISTA_ITEMS_PRESUPUESTO_ACTIVO")
@(Html.EJ().Grid<object>("ITEMS_PRESUPUESTOGrid")
.Datasource(ds => ds.URL("GetOrderData_VISTA_ITEMS_PRESUPUESTO_ACTIVO").Adaptor(AdaptorType.UrlAdaptor))
//.AllowScrolling()
//.ScrollSettings(col => { col.Width(520).Height(300).EnableVirtualization(true); })
.AllowPaging()
.AllowFiltering()
.QueryString("COD_SUBCAPITULO")
.Locale("es-CO")
.AllowResizeToFit(true)
.AllowResizing(false)
.AllowMultiSorting()
.AllowSorting()
.PageSettings(page => page.PageSize(7))
.ClientSideEvents(eve => eve.ToolbarClick("clickedderecha"))
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Normal); })
.ClientSideEvents(e => e.Load("load_VISTA_ITEMS_PRESUPUESTO_ACTIVOGrid").Create("create_grid_ITEMS_PRESUPUESTOGrid").ActionBegin("inicio").ActionBegin("inicio_grid_VISTA_ITEMS_PRESUPUESTO_SIN_CONTRATOGrid").Create("create_grid_VISTA_ITEMS_PRESUPUESTO_SIN_CONTRATOGrid"))
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Search);
});
}).Columns(col =>
{
col.Field("COD_ITEM").HeaderText("CÓDIGO").IsPrimaryKey(true).Visible(true).Add();
col.Field("NOMBRE").HeaderText("NOMBRE").Add();
col.Field("CANTIDAD").HeaderText("C. PRESU.").Add();
col.HeaderText("C. A REG").EditType(EditingType.NumericEdit).Add();
})
这是控制器:
public ActionResult GetOrderData_VISTA_ITEMS_PRESUPUESTO_ACTIVO(DataManager dm)
{
IEnumerable DataSource = db.VISTA_ITEMS_PRESUPUESTO_ACTIVO.ToList();
DataOperations ds = new DataOperations();
List<string> str = new List<string>();
db.Configuration.ProxyCreationEnabled = false;
db.Configuration.LazyLoadingEnabled = false;
return Json(new { result = DataSource }, JsonRequestBehavior.AllowGet);
}
public ActionResult GetOrderData\u VISTA\u ITEMS\u prespuesto\u ACTIVO(DataManager dm)
{
IEnumerable DataSource=db.VISTA_ITEMS_prespuesto_ACTIVO.ToList();
DataOperations ds=新的DataOperations();
List str=新列表();
db.Configuration.ProxyCreationEnabled=false;
db.Configuration.LazyLoadingEnabled=false;
返回Json(新的{result=DataSource},JsonRequestBehavior.AllowGet);
}
如果有人能帮助我,我非常感激 我在官方文档中找到了一个解决方案
}).Columns(col => {
col.Type("checkbox").HeaderText("").Field("").Width("60").AllowFiltering(false).AllowSorting(false).Add();
col.Field("COD_ITEM").HeaderText("CÓDIGO").IsPrimaryKey(true).Visible(false).col.Field("NOMBRE").HeaderText("NOMBRE").Add();
col.Field("CANTIDAD").HeaderText("C. DISPONIBLE").Add();
col.HeaderText("C. ADD").Template("<input value=0 />").Add();
})。列(列=>{
col.Type(“复选框”).HeaderText(“”).Field(“”).Width(“60”).AllowFiltering(false).AllowSorting(false).Add();
col.Field(“COD_ITEM”).HeaderText(“CÓDIGO”).IsPrimaryKey(true).可见(false).col.Field(“NOMBRE”).HeaderText(“NOMBRE”).Add();
col.Field(“CANTIDAD”).HeaderText(“C.disponable”).Add();
col.HeaderText(“C.ADD”).Template(“”.ADD();
我添加了两个可编辑字段,一个是检查字段,另一个是输入字段,我共享链接以扩展信息:
根据您的示例,最后一列没有字段属性。因此,最后一列显示空值。根据您的查询,您正在使用多个表生成网格。因此,我们建议您使用外键列。请参阅以下代码段: 您的代码:
col.Field("NOMBRE").HeaderText("NOMBRE").Add();
col.Field("CANTIDAD").HeaderText("C. PRESU.").Add();
col.HeaderText("C. A REG").EditType(EditingType.NumericEdit).Add();
.
修改代码:
col.Field("OrderID").HeaderText("CÓDIGO").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("NOMBRE").TextAlign(TextAlign.Right).EditType(EditingType.NumericEdit).Width(75).Format("{0:C}").Add();
col.Field("ShipCity").HeaderText("C. PRESU.").Width(80).Add();
col.Field("EmployeeID").HeaderText("C. A REG").ForeignKeyField("EmployeeID").ForeignKeyValue("FirstName").DataSource(ViewBag.data).TextAlign(TextAlign.Right).Width(90).Add();
请参阅以下帮助文档:
请参考修改后的样本:
这个问题不是很清楚。您可以添加更多关于如何编辑值、如何将值发布到数据库(此代码)以及如何保存记录的信息吗?完成,已经添加了更多信息,谢谢您的建议
col.Field("OrderID").HeaderText("CÓDIGO").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("NOMBRE").TextAlign(TextAlign.Right).EditType(EditingType.NumericEdit).Width(75).Format("{0:C}").Add();
col.Field("ShipCity").HeaderText("C. PRESU.").Width(80).Add();
col.Field("EmployeeID").HeaderText("C. A REG").ForeignKeyField("EmployeeID").ForeignKeyValue("FirstName").DataSource(ViewBag.data).TextAlign(TextAlign.Right).Width(90).Add();