Asp.net mvc 4 存在dojo网格时在asp.net MVC中处理表单Post
我对基于web的应用程序开发非常陌生。我正在使用ASP.NETMVC4和DojoToolkit。我的要求就像我有特定的文本框来捕获数据,还有一个dojo网格来捕获表格格式的特定细节。因此,我将Dojo grid()与ItemFileWriteStore一起使用。我的观点如下(我正在使用剃须刀)Asp.net mvc 4 存在dojo网格时在asp.net MVC中处理表单Post,asp.net-mvc-4,dojox.grid.datagrid,Asp.net Mvc 4,Dojox.grid.datagrid,我对基于web的应用程序开发非常陌生。我正在使用ASP.NETMVC4和DojoToolkit。我的要求就像我有特定的文本框来捕获数据,还有一个dojo网格来捕获表格格式的特定细节。因此,我将Dojo grid()与ItemFileWriteStore一起使用。我的观点如下(我正在使用剃须刀) 我的问题是因为网格在表单中,每当我添加或删除一行时,页面都会被提交到表单中提到的Post方法。我只需要发布整个数据,这样我就可以一起处理了。所以我把我的格子移到了表格外面。现在我对如何捕获整个数据(文本框
我的问题是因为网格在表单中,每当我添加或删除一行时,页面都会被提交到表单中提到的Post方法。我只需要发布整个数据,这样我就可以一起处理了。所以我把我的格子移到了表格外面。现在我对如何捕获整个数据(文本框和网格中的数据)并提交给控制器方法感到困惑。请帮帮我 为了防止整个页面被提交到Post方法,您应该使用ajax解决方案来发送和接收数据 看看这个: 而这个:。我希望他们能帮上忙
@using (Html.BeginForm("CreateNewData", "Home", FormMethod.Post, new { id = "myForm" }))
{
<div class="controlWrapper">
<div class="controlLabel">
@Html.DisplayNameFor(model => model.Name)
</div>
<div class="controlValue">
@Html.TextBoxFor(model => model.Name)
</div>
</div>
<div class="controlWrapper">
<h4>
Table Items</h4>
<div id="myGrid">
</div>
<div id="addRemoveMode">
<button data-dojo-type="dijit.form.Button" id="addButton" onclick="addRecord()">
Add</button>
<button data-dojo-type="dijit.form.Button" id="removeButton" onclick="removeRecord()">
Remove Selected Rows
</button>
</div>
</div>
}
require(["dojo/ready",
"dojox/grid/DataGrid",
"dojo/data/ItemFileWriteStore",
"dojo/json",
"dojo/query",
"dijit/form/TextBox"
], function (ready, DataGrid, ItemFileWriteStore, Json, query, TextBox) {
ready(function () {
var layout = [[
{ name: 'ID', field: 'ID', hidden: true },
{ name: 'Label', field: 'Label', width: '10%', editable: true },
{ name: 'Position', field: 'Position', width: '10%', editable: true }
]];
var attCodeData = {
identifier: 'ID',
items: []
};
console.log(globalVar);
attCodeData["items"] = globalVar;
myStore= new ItemFileWriteStore({ data: attCodeData })
myGrid= new DataGrid({
store: myStore,
structure: layout,
rowSelector: '20px'
},"divGrid");
myGrid.startup();
}