Grid.mvc表单提交中断了paiging功能 [英] Grid.mvc form submit breaks paiging feature
问题描述
Grid.MVC呈现一个非常漂亮的网格来显示数据。但是,由于没有内联编辑的规定,因此必须使用基于网格数据的单独表单和文本框来更改/添加记录。
这迫使开发人员使用表单提交将数据发送到SAVE()例程。避免破坏分页的唯一方法是使用GET方法发送数据t DB例程。
我已经尝试过使用表单对象和表单集合,但这些方法开辟了自己的味道罐装蠕虫。
有没有人知道修改网格代码以使用POST方法玩得很好的方法?
******** Razor查看**********
@using(Html.BeginForm(SaveNewClient,Client,FormMethod.Get))
{
NewForm
@ Html.Grid(型号).Columns(columns =>
{
//columns.Add(c => c.Id).Titled(ID)
// .Sanitized(false)
// .Encoded(false)
// .RenderValueAs(Model => Html.TextBox(ID,Model.Id));
columns.Add()
.Sanitized(false)
.Encoded(false)
.RenderValueAs(Model => Html.TextBox(Name,Model.Name,Name));
columns.Add ()
.Sanitized(false)
.Encoded(false)
.RenderValueAs(Mod el => Html.TextBox(Email,Model.Email,Email));
//columns.Add()
/ / .Sanitized(false)
// .Encoded(false);
})。WithPaging (3,10,)。舒适(真实)
***************************** *****************************************
< br $>
***************控制器******************* **********
[HttpGet]
public ActionResult SaveNewClient()
{
// Perists将chagnes记录到数据库
const string PROCNAME =SaveNewClient;
try
{
// int id = Convert.ToInt32(Request [ID]);
// Routine(实际存储的proc。)将检查是否存在此ID
//并更新现有记录或创建新记录。
//Request.Form [name]。ToString();
//clientMethods.SaveClient(Convert.ToInt32(collection[\"ClientGrid.id]。 ToString()),collection [Name],collection [ClientGrid.Email]);
clientMethods.SaveNewClient(Request [Name]。ToString(),Request [Email ] .ToString());
列出客户= clientMethods.GetClients();
返回查看(索引,客户);
}
catch(exception ex)
{
ProgLog.Log(ex.Message,PROCNAME,MODNAME);
返回null;
}
}
*********** ************************************************** *
提前感谢您的回复。
我尝试过的:
表格对象
表格集合
去除头发wi暴力手势。
我正在使用grid.mvc BTW,它正在抓取寻呼功能的URL信息。
Grid.MVC renders a very nice looking grid for displaying data. However, since there is no provision for inline editing, one must use a separate form and text boxes, based on grid data, for changing/adding records.
This forces the developer to use a form submit to send data to SAVE() routines. The only way to avoid breaking the paging is via the use of a GET method to send data t DB routines.
I have have tried using form objects and form collections but those approaches open up their own flavor a canned worms.
Does anyone know of a way to modify the Grid code to play nice with a POST method?
******** Razor View **********
@using (Html.BeginForm("SaveNewClient", "Client", FormMethod.Get))
{
NewForm
@Html.Grid(Model).Columns(columns =>
{
//columns.Add(c => c.Id).Titled("ID")
// .Sanitized(false)
// .Encoded(false)
// .RenderValueAs(Model => Html.TextBox("ID", Model.Id));
columns.Add()
.Sanitized(false)
.Encoded(false)
.RenderValueAs(Model => Html.TextBox("Name", Model.Name, "Name" ));
columns.Add()
.Sanitized(false)
.Encoded(false)
.RenderValueAs(Model => Html.TextBox("Email", Model.Email, "Email"));
//columns.Add()
// .Sanitized(false)
// .Encoded(false);
}).WithPaging(3, 10, "").Sortable(true)
**********************************************************************
*************** Controller *****************************
[HttpGet]
public ActionResult SaveNewClient()
{
// Perists record chagnes to database
const string PROCNAME = "SaveNewClient";
try
{
//int id = Convert.ToInt32(Request["ID"]);
// Routine (actually stored proc.) will check for the existence of this ID
// and update an existing records or create a new.
//Request.Form["name"].ToString();
//clientMethods.SaveClient(Convert.ToInt32(collection["ClientGrid.id"].ToString()), collection["Name"], collection["ClientGrid.Email"]);
clientMethods.SaveNewClient(Request["Name"].ToString(), Request["Email"].ToString());
List clients = clientMethods.GetClients();
return View("Index", clients);
}
catch(Exception ex)
{
ProgLog.Log(ex.Message, PROCNAME, MODNAME);
return null;
}
}
**************************************************************
Thank you, in advance, for your responses.
What I have tried:
Form objects
Form collections
Removing hair with violent hand gestures.
I am using grid.mvc BTW which is grabbing URL info for paging feature.
推荐答案
I should have stated in the original question that I am employing Grid.MVC.
这篇关于Grid.mvc表单提交中断了paiging功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!