Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove rows using Jquery when unchecked
    text
    copied!<p>I am looking for a success : function which removes the checked rows when the Delete Action completes. Now I need to refresh every time to check whether the row is deleted</p> <p>Here's my Jquery</p> <pre><code> $('#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; }); </code></pre> <p>My controller </p> <pre><code>public ActionResult Delete() { return View(); } [HttpPost] public void Delete(List&lt;int&gt; ids) { int[] TXId = ids.ToArray(); foreach (int i in TXId) { int deleted = new Voucher().Delete(i); } } </code></pre> <p>My model (only Delete)</p> <pre><code>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 } </code></pre> <p>and attaching my view</p> <pre><code>&lt;table class="tab sortable" id="sortabletable"&gt; &lt;tr class="heading"&gt; &lt;th&gt; Date &lt;/th&gt; &lt;th id="to"&gt; To&lt;/th&gt; &lt;th&gt; Voucher ID &lt;/th&gt; &lt;th&gt; Description &lt;/th&gt; &lt;th&gt; Amount &lt;/th&gt; &lt;th&gt; Account &lt;/th&gt; &lt;th&gt; User&lt;/th&gt; &lt;th&gt;Select &lt;/th&gt; &lt;/tr&gt; @foreach (var item in Model.MyList) { &lt;tr class="rows"&gt; &lt;td&gt; @item.Date.ToShortDateString() &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItm =&gt; item.Per) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.VId) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.Des) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.Amt) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.AId) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.UId) &lt;/td&gt; &lt;td&gt;&lt;input type="checkbox" name="thecheckbox" value="@item.TXId" class ="cbox" checked/&gt;&lt;/td&gt; &lt;/tr&gt; } &lt;/table&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload