0
내가 성공을 찾고 있는데 : 삭제 동작이 완료되면 확인 된 행을 제거하는 기능. 지금은선택하지 않은 경우 Jquery를 사용하여 행 제거
namespace Finance.Models
{
public class Voucher
{
public int Delete(int TXId)
{
using (SqlConnection con = new SqlConnection(CONNECTION_STRING))
{
using (SqlCommand cmd = new SqlCommand("DELETE FROM Ledger WHERE TXId = @TXID", con))
{
con.Open();
cmd.Parameters.AddWithValue("@TXID", TXId);
int modified = cmd.ExecuteNonQuery();
if (con.State == System.Data.ConnectionState.Open) con.Close();
return modified;
}
}
}
#endregion
}
(만 삭제) 행이
여기$('#del').click(function() {
var delData = [];
$("input:checked").each(function() {
delData.push($(this).val());
});
$.ajax({
type: "POST",
url: "/Home/Delete",
data: { 'ids': delData },
success: function (data) {
if (data = true) {
jQuery("tr input:checked").remove(this);
}
else {
alert("yooo")
}
},
dataType: "json",
traditional: true
});
return false;
});
내 컨트롤러
public ActionResult Delete()
{
return View();
}
[HttpPost]
public void Delete(List<int> ids)
{
int[] TXId = ids.ToArray();
foreach (int i in TXId)
{
int deleted = new Voucher().Delete(i);
}
}
내 모델 내 jQuery의 삭제 여부를 확인하기 위해 모든 시간을 새로 고쳐야 내보기 첨부하기
당신의 성공 함수에서 행 다음에<table class="tab sortable" id="sortabletable">
<tr class="heading">
<th>
Date
</th>
<th id="to">
To</th>
<th>
Voucher ID
</th>
<th>
Description
</th>
<th>
Amount
</th>
<th>
Account
</th>
<th> User</th>
<th>Select </th>
</tr>
@foreach (var item in Model.MyList) {
<tr class="rows">
<td>
@item.Date.ToShortDateString()
</td>
<td>
@Html.DisplayFor(modelItm => item.Per)
</td>
<td>
@Html.DisplayFor(modelItem => item.VId)
</td>
<td>
@Html.DisplayFor(modelItem => item.Des)
</td>
<td>
@Html.DisplayFor(modelItem => item.Amt)
</td>
<td>
@Html.DisplayFor(modelItem => item.AId)
</td>
<td>
@Html.DisplayFor(modelItem => item.UId)
</td>
<td><input type="checkbox" name="thecheckbox" value="@item.TXId" class ="cbox" checked/></td>
</tr>
}
</table>
는 다시 한번 감사드립니다 ... 하, 하,은 간단합니다 .... 주셔서 감사합니다 .. 말하는 – JRU
방법은 받아 투표한다 유래에 감사합니다 :) –
조금 더 많은 평판이 필요하다는 것을 알고 있지만 – JRU