1

I have searched for help but can find any topic that could help me. I have a table like this

<table id="tableftest" class="table table-striped table-vmiddle">
            <thead>
                <tr>
                    <th data-column-id="" data-sortable="false">
                        <input type="checkbox" id="checkall" title="chọn tất cả" onclick="" />
                    </th>
                    <th data-column-id="ip">IP</th>
                    <th data-column-id="network" hidden="hidden">Network</th>
                    <th data-column-id="sender">GateWay</th>
                    <th data-column-id="received">SubnetMask</th>
                    <th data-column-id="viewdetail">VPS được gán</th>
                    @*<th data-column-id="commands" data-formatter="commands" data-sortable="false"></th>*@
                </tr>
            </thead>
            <tbody>
                @foreach (VPSIP ipitem in ip)
                {
                    <tr>
                        @if (ipitem.VPSID != null)
                        {
                            <td></td>
                        }
                        else
                        {
                            <td>
                                <input type="checkbox" class="ipDelListClass" name="ipDelList" value="@ipitem.IpID" />
                            </td>
                        }

                        <td>@(ipitem.IPAddress)</td>
                        <td hidden="hidden">@ipitem.NetworkRanx.NetworkAddress</td>
                        <td>@(ipitem.NetworkRanx.Gateway)</td>
                        <td>@ipitem.NetworkRanx.SubnetMask</td>
                        @if (ipitem.VPSID != null)
                        {
                            <td><a href="@Url.Action("VPSDetail", "TechnicalStaff", new {ipitem.VPSID })">@(ipitem.VPSs.VPSName)</a></td>
                            @*<td></td>*@
                        }
                        else
                        {
                            <td></td>
                            @*<td>
                                <button title="Xóa ip" class="btn btn-danger zmdi zmdi-delete" data-toggle="modal" data-target="#IpDel_@ipitem.IpID" style="font-size:medium"></button>
                            </td>*@
                        }
                    </tr>
                }
            </tbody>
        </table>

When I check all checkboxs in table and click button delete, it will post data to this controller

[HttpPost]
    public ActionResult IPDeleteMany(FormCollection f)
    {
        var ipDelArray = f.Get("ipDelList");
        ServerBusiness serBu = new ServerBusiness();
        string[] ipDelList = ipDelArray.Split(',');
        try
        {
            foreach (string ipId in ipDelList)
            {
                var iprow = serBu.getIPById(int.Parse(ipId));
                serBu.removeIPById(iprow);
            }
            TempData["Success"] = "IP đã bị xóa!";
            return RedirectToAction("ViewListIP", "TechnicalStaff");
        }
        catch
        {
            TempData["Error"] = "Lỗi!";
            return RedirectToAction("ViewListIP", "TechnicalStaff");
        }
    }

When it runs, it only get values of rows that is visible, not all the rows in table.

Is there anyway to get all of values checked in table include invisible rows?

1 Answers1

1

change your hidden="hidden" to style="display:none;".

And for you other pages, because you didnt use Ajax your data isn't exist in fact, so you can:

  • use Ajax and hide your old rows and append new rows where exist all of your desired rows in your html however some of them be hidden.
  • force your users to submit current page data and then switch pages.
Community
  • 1
  • 1
vahid kargar
  • 800
  • 1
  • 9
  • 23