我需要使用 ajax 更新网格中更改的行
I need to update the changed row in the grid using ajax
我是jqGrid的新手,我真的需要帮助。
单击 "submit" 后,我想使用 Ajax 更新行而不重新加载页面。告诉我需要写什么。
我的代码
我可以通过更新页面来更新数据,但我需要它而不需要更新
View
{
//edit
url: '@Url.Action("Edit", "TableDocument")',
closeAfterEdit: true,
height: 250,
width: 400,
afterSubmit: function(responce) {
$("#jqg").jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
return [true, responce.responseText];
}
},
Controller
private static bool tuggel = false;
private DataContext db = new DataContext();
private Testing testing = new Testing();
public TableDocumentController()
{
if (!tuggel)
{
testing.DataList();
tuggel = true;
}
}
public ActionResult Test()
{
return View();
}
public string GetData()
{
return JsonConvert.SerializeObject(db.DataBases);
}
[HttpPost]
public void Edit(DataBase data)
{
try
{
db.Entry(data).State = EntityState.Modified;
db.SaveChanges();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
你应该使用 reloadAfterSubmit option 设置为 false
{
//edit
url: '@Url.Action("Edit", "TableDocument")',
closeAfterEdit: true,
reloadAfterSubmit : false,
height: 250,
width: 400,
afterSubmit: function(responce) {
$("#jqg").jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
return [true, responce.responseText];
}
},
我是jqGrid的新手,我真的需要帮助。
单击 "submit" 后,我想使用 Ajax 更新行而不重新加载页面。告诉我需要写什么。
我的代码
我可以通过更新页面来更新数据,但我需要它而不需要更新
View
{
//edit
url: '@Url.Action("Edit", "TableDocument")',
closeAfterEdit: true,
height: 250,
width: 400,
afterSubmit: function(responce) {
$("#jqg").jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
return [true, responce.responseText];
}
},
Controller
private static bool tuggel = false;
private DataContext db = new DataContext();
private Testing testing = new Testing();
public TableDocumentController()
{
if (!tuggel)
{
testing.DataList();
tuggel = true;
}
}
public ActionResult Test()
{
return View();
}
public string GetData()
{
return JsonConvert.SerializeObject(db.DataBases);
}
[HttpPost]
public void Edit(DataBase data)
{
try
{
db.Entry(data).State = EntityState.Modified;
db.SaveChanges();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
你应该使用 reloadAfterSubmit option 设置为 false
{
//edit
url: '@Url.Action("Edit", "TableDocument")',
closeAfterEdit: true,
reloadAfterSubmit : false,
height: 250,
width: 400,
afterSubmit: function(responce) {
$("#jqg").jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
return [true, responce.responseText];
}
},