如何使用JavaScript在客户端隐藏网格行 [英] how to hide the row of grid at client side using javascript
问题描述
你好朋友,
我正在尝试使用带jquery的ajax从网格中删除记录.我能够从数据库中删除记录,但同时我想从网格中删除行.
如何参考,哪一行已被删除?
我尝试了以下操作:
Hello friends,
I was trying to delete record from grid using ajax with jquery. I was able to delete the record from database but at the same time I want to remove the row from grid.
How can I refer, which row has been deleted?
I tried following:
function funDelete(id,row) {
alert("Start");
if (confirm("Do you want to delete this record?")) {
alert("Step 1");
try {
//GET ID OF RECORD TO BE DELETED
alert("ID:" + id);
$.ajax({
type: "POST",
url: "QCNotice.aspx/deleteComment",
data: "{''args'':''" + id + "''}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function() {
alert("Record has been deleted..");
//CODE TO HIDE THE ROW
row.css("background-color", "Red");
row.fadeOut(500, function() {
row.remove();
});
});
},
error: function(event, request, settings) {
alert(request);
}
});
}
catch (e) {
alert("Error:" + e.message);
}
}
return false;
}
在函数中,我传递记录ID
In the function, I''m passing the record ID
Dim lnkDelete As New LinkButton
lnkDelete = gvRow.FindControl("lnkDelete")
Dim intID As Integer = lnkDelete.CommandArgument
lnkDelete.Attributes.Add("onclick", "return funDelete(" & intID & "," & e.Row.RowIndex & ");")
即使尝试,也不起作用
Even trying, its not working
row.css("background-color", "Red");
row.fadeOut(500, function() {
row.remove();
});
如何使用rowindex隐藏行?
有什么主意吗?
在此先感谢
How can I use rowindex to hide row?
Any idea?
Thanks in advance
推荐答案
.ajax({ 输入:"POST", 网址:"QCNotice.aspx/deleteComment", 数据:"{" args:""+ id +"''}, contentType:"application/json; charset = utf-8", dataType:"json", 成功:function(){ alert(记录已被删除.."); //隐藏行的代码 row.css("background-color","Red"); row.fadeOut(500,function(){ row.remove(); }); }); }, 错误:功能(事件,请求,设置){ 警报(请求); } }); } 抓住(e){ alert(错误:" + e.message); } } 返回false; }
.ajax({ type: "POST", url: "QCNotice.aspx/deleteComment", data: "{''args'':''" + id + "''}", contentType: "application/json; charset=utf-8", dataType: "json", success: function() { alert("Record has been deleted.."); //CODE TO HIDE THE ROW row.css("background-color", "Red"); row.fadeOut(500, function() { row.remove(); }); }); }, error: function(event, request, settings) { alert(request); } }); } catch (e) { alert("Error:" + e.message); } } return false; }
在函数中,我传递记录ID
In the function, I''m passing the record ID
Dim lnkDelete As New LinkButton
lnkDelete = gvRow.FindControl("lnkDelete")
Dim intID As Integer = lnkDelete.CommandArgument
lnkDelete.Attributes.Add("onclick", "return funDelete(" & intID & "," & e.Row.RowIndex & ");")
即使尝试,也不起作用
Even trying, its not working
row.css("background-color", "Red");
row.fadeOut(500, function() {
row.remove();
});
如何使用rowindex隐藏行?
有什么主意吗?
预先感谢
How can I use rowindex to hide row?
Any idea?
Thanks in advance
您好,
您不需要从网格中删除记录,只需将网格重新绑定到客户端即可进行更改.
问候,
shefeek
Hi,
You does''nt need to delete the record from the grid,you just rebind the grid in cliet side for the changes.
regards,
shefeek
这篇关于如何使用JavaScript在客户端隐藏网格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!