Jquery 添加新对话框jqGrid(navGrid)后的消息
嗨,我在添加操作中有这个Jquery 添加新对话框jqGrid(navGrid)后的消息,jquery,jqgrid,return,message,Jquery,Jqgrid,Return,Message,嗨,我在添加操作中有这个navGrid定义 Grid.id >> $("#<%=Me.Id & "_" %>lstPreciosSUD") { width: 350, resize: false, closeAfterAdd: false, recreateForm: true, clearAfterAdd:false, viewPagerButtons: true, afterComplete: estadoReplicado, ,afterS
navGrid
定义
Grid.id >> $("#<%=Me.Id & "_" %>lstPreciosSUD")
{ width: 350, resize: false, closeAfterAdd: false, recreateForm: true,
clearAfterAdd:false, viewPagerButtons: true, afterComplete: estadoReplicado,
,afterSubmit: function(response) {
if (response.responseText == "OK") {
alert("we are inside");
var myInfo = '<div class="ui-state-highlight ui-corner-all">' +
'<span class="ui-icon ui-icon-info" ' +
'style="float: left; margin-right: .3em;"></span>' +
'<span>Registro insertado correctamente!</span></div>',
$infoTr,
$infoTd;
$infoTr = $("#TblGrid" + "<%=Me.Id & "_" %>lstPreciosSUD" + ">tbody>tr.tinfo");
$infoTd = $infoTr.children("td.topinfo");
$infoTd.html(myInfo);
$infoTr.show();
setTimeout(function () {
$infoTd.children("div")
.fadeOut("slow", function () {
$infoTr.hide();
});
}, 6000);
//alert("Registro creado.");
return [true,''];
}
else {
return [false, "Error creando precio de suplemento!"];
}
},
beforeSubmit: function(postdata){
if ((postdata.tpb_importe == "") || (postdata.fini == "") || (postdata.ffin=="")) {
return[false,"Importe y fechas es obligatorio!"];
} else { return [true,""] }
}
}}
Grid.id>>$(“#lstpriciossud”)
{width:350,resize:false,closeAfterAdd:false,recreateForm:true,
clearAfterAdd:false,viewPagerButtons:true,afterComplete:estadoReplicado,
,后提交:函数(响应){
如果(response.responseText==“确定”){
警惕(“我们在里面”);
var myInfo=''+
'' +
“Registro insertado correctamente!”,
$infoTr,
$infoTd;
$infoTr=$(“#TblGrid”+“lstpriciossud”+”>tbody>tr.tinfo”);
$infoTd=$infoTr.children(“td.topinfo”);
$infoTd.html(myInfo);
$infoTr.show();
setTimeout(函数(){
$infoTd.儿童(“div”)
.衰减(“慢”,功能(){
$infoTr.hide();
});
}, 6000);
//警报(“Registro creado”);
返回[true',];
}
否则{
返回[false,“Error creando precio de suplemento!”;
}
},
beforeSubmit:函数(postdata){
如果((postdata.tpb_import==“”)postdata.fini==“”)postdata.ffin==“”){
返回[false,“进口粪便有义务!”;
}else{return[true,“]}
}
}}
在第二个或日期的输入中,如果为空,此返回(return[false,“Importe y feces obligatorio!””
)会在对话框中从提交前的返回一条红色消息,如下所示
在这种情况下,我必须使用closeAfterAdd:false
和clearAfterAdd:false
,但我想知道,我想使用afterSubmit
显示绿色(例如)消息如果用一个小函数就可以了,但是如果我使用上面的afterSubmit
函数,并且它是确定的,不显示任何消息,比如错误消息,可以显示任何确定消息吗?如果有错误,它会以红色显示,我在后台看不到它是如何添加新记录的,但在对话框中不显示任何消息
谢谢。如果我理解您的意思是正确的,您将在中找到此类实现的示例(请参阅)。它显示了如何使用添加自定义文本的方法,与添加标准错误消息的方法相同。在演示中,我使用了errorTextFormat
,仅用于模拟加载。您应该在afterSubmit
中移动显示成功消息的代码
已更新:提交后的代码可能看起来像(我没有测试代码)
afterSubmit:function(jqXHR){
var myInfo=''+
'' +
“行已成功添加”,
$infoTr,
$infoTd;
如果(jqXHR.responseText!=“确定”){
返回[false,jqXHR.responseText];
}
$infoTr=$(“#TblGrid_389;”+$.jgrid.jqID(this.id)+>tbody>tr.tinfo”),
$infoTd=$infoTr.children(“td.topinfo”);
$infoTd.html(myInfo);
$infoTr.show();
//在3秒超时后隐藏信息
setTimeout(函数(){
$infoTd.儿童(“div”)
.衰减(“慢”,功能(){
//动画完成。
$infoTr.hide();
});
}, 3000);
}
Hi Oleg!我在答案中看不到你的errorTextFormat代码。你能帮我吗?我已经在所有答案链接页面中搜索了!再次感谢!@bombai:你可以打开的源代码。如果你有问题,我可以在我的答案中添加部分代码。Hi Oleg!我可以看到代码,但我不知道应该在哪里以及如何使用!我必须将直接在提交后在寻呼机中调用它或它不是必需的?再次感谢。嗨,OLeg!如果我将此代码放入“添加”或“编辑”操作中而不返回true,则可以保存新数据,如果我将return[true],]保存数据,但不显示任何消息!你知道吗?我已经编辑了第一篇文章,介绍了我是如何获得代码的!Thanks@bombai:不客气!图标的颜色将从您使用的jQuery UI CSS获得。因此,您可以根据自定义主题。或者,您可以混合使用其他著名CSS(如le frog)的图标其中包含绿色图标。若你们在实现上有问题,你们可以问新问题,我会尽力帮助你们。
afterSubmit: function (jqXHR) {
var myInfo = '<div class="ui-state-highlight ui-corner-all">' +
'<span class="ui-icon ui-icon-info" ' +
'style="float: left; margin-right: .3em;"></span>' +
'<span>The row is successfully added</span></div>',
$infoTr,
$infoTd;
if (jqXHR.responseText !== "OK") {
return [false, jqXHR.responseText];
}
$infoTr = $("#TblGrid_" + $.jgrid.jqID(this.id) + ">tbody>tr.tinfo"),
$infoTd = $infoTr.children("td.topinfo");
$infoTd.html(myInfo);
$infoTr.show();
// hide the info after 3 sec timeout
setTimeout(function () {
$infoTd.children("div")
.fadeOut("slow", function () {
// Animation complete.
$infoTr.hide();
});
}, 3000);
}