在kendo网格中追加新行时,我的先前数据将被清除 [英] On appending new row in kendo grid my previous datas gets cleared
问题描述
在我的项目中,我动态地向kendo网格添加新行。我将数据输入到该行。但是在向网格添加新行时,输入的数据将被清除。我正在尝试添加批量创建记录。在这里,我在所有列中使用了kendo小部件。我的代码是
In my project,i dynamically adding new rows to the kendo grid.I entered datas to that row.But on appending new row to the grid the entered datas gets cleared.I am trying to add batch creating of records. here i used kendo widgets in all columns.My code is
@(Html.Kendo().Grid<POC_Grid.TblProductDetails>()
.Name("Grid")
.Columns(column =>
{
//column.Template(m => m.Id);
column.Template(m => m.Item).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().AutoComplete()
.Name("Item#=uid#")
.DataTextField("Item")
.Filter("startswith")
.MinLength(1)
.HtmlAttributes(new { style = "width:250px", @class = "templateCell" })
.DataSource(source =>
{
source.Read(read =>
{
read.Action("getFilteredData", "Grid")
.Data("filterDataByText");
})
.ServerFiltering(true);
})
.ToClientTemplate().ToHtmlString());
column.Template(m => m.Units).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().NumericTextBox<decimal>()
.Name("Units#=uid#")
.Format("c")
.Min(0)
.Max(100)
.HtmlAttributes(new { @class = "templateCell" })
.ToClientTemplate().ToHtmlString());
column.Template(m => m.SingleUnitPrice).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().NumericTextBox<decimal>()
.Name("SingleUnitPrice#=uid#")
.Format("c")
.Min(0)
.Max(100)
.HtmlAttributes(new { @class = "templateCell" })
.ToClientTemplate().ToHtmlString());
column.Template(m => m.Total).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().NumericTextBox<decimal>()
.Name("Total#=uid#")
.Min(0)
.Max(100)
//.HtmlAttributes(new { @readonly = "readonly" })
.HtmlAttributes(new { @class = "templateCell",@title="total" })
.ToClientTemplate().ToHtmlString());
})
.Events(ev => ev.DataBound("templateScript")
)
.ToolBar(toolbar =>
{
toolbar.Create().Text("+");
toolbar.Save();
})
.Editable(m => m.Mode(GridEditMode.InCell))
.Pageable(p=>p.Refresh(false))
.Sortable()
.Scrollable()
.Selectable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Model(model =>
{
model.Id(p => p.Id);
})
.PageSize(20)
//.Model(m => { m.Id(c => c.Id); })
.Create(create => create.Action("Grid_Create", "Grid"))
.Update(update => update.Action("Grid_Update", "Grid"))
//.Read(read => read.Action("Grid_Read", "Grid"))
)
我的剑道装订事件是:
My kendo bound event is:
<script>
function templateScript(e) {
$(".templateCell").each(function () {
eval($(this).children("script").html());
});
}
</script>
用于追加我使用的新行
For appending new row i used
var grid = $("#Grid").data("kendoGrid");
grid.addRow()
附加新行后,现有的行数据被清除。我认为这些是由于数据源而发生的清除.Plz告诉一些建议来克服这些问题。在追加新行时,现有的行数据无法清除。如果我试图将批量保存添加到数据库。它只保存空值。我试了这么多个小时。我无法获得正确的解决方案。
< / script>
After appending new row the existing row datas gets cleared.I think these occurs due to datasource is cleared.Plz tell some suggestion to overcome these problem.On appending new rows the existing row datas cannot get cleared.And if i tried to add batch save to database.It saves null values only.I tried these for so many hours.I couldn't get proper solutions.
</script>
推荐答案
( 。templateCell)。each( function (){
eval (
(".templateCell").each(function () { eval(
( this )。children( script)。html());
});
}
< / script>
(this).children("script").html()); }); } </script>
用于追加我使用的新行
For appending new row i used
var grid =
( #网格)。data( kendoGrid);
grid.addRow()
("#Grid").data("kendoGrid"); grid.addRow()
附加新行后,现有的行数据被清除。我认为这些是由于数据源而发生的清除.Plz告诉一些建议来克服这些问题。在追加新行时,现有的行数据无法清除。如果我试图将批量保存添加到数据库。它只保存空值。我试了这么多个小时。我无法获得适当的解决方案。
< / script>
After appending new row the existing row datas gets cleared.I think these occurs due to datasource is cleared.Plz tell some suggestion to overcome these problem.On appending new rows the existing row datas cannot get cleared.And if i tried to add batch save to database.It saves null values only.I tried these for so many hours.I couldn't get proper solutions.
</script>
这篇关于在kendo网格中追加新行时,我的先前数据将被清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!