梦若夕阳海
穷其一生的追求

主要针对页面table表中多项选择所进行的批量审核的操作:

页面html代码:

<table>
                        <tr>
                             <th>
                                <input type="checkbox" name="ckall" id="ckall" />  //表格中第一行控制是否全选
                            </th>
                            <th>
                                订单编号
                            </th>
                          
                            <th>
                                联系人
                            </th>
                            <th>
                                电话或手机
                            </th>
                            <th>
                                Email
                            </th>
                            <th>
                                订购日期
                            </th>
                            <th>
                                审核状态
                            </th>
                            <th>
                            </th>
                          
                        </tr>
                       
                            foreach (var item in Model.Collection)   //这是我用mvc框架举得一个列子,强类型绑定数据,对数据进行循环遍历
                            {
                            <tr>
                                <td>
                                    <input type="checkbox" name="ckitem" value="@item.ID"  />  //选择项
                                </td>
                                <td>@item.OrderNo
                                </td>
                              
                                <td>@item.LinkMan
                                </td>
                                <td>@item.TelOrMobile
                                </td>
                                <td>@item.Email
                                </td>
                                <td>@item.OrderDate
                                </td>
                                <td>
                                @if(!item.TripStatus)
                                {
                                    <div style="color:Red">未审核</div>
                                }
                               else
                               {
                                    <div>已审核</div>
                                }
                                </td>
                                <td>
                               
                                    @Html.ActionLink("审核", "GetStatus", "SuperMarket", new { Id = @item.ID }, null)
                              
                                </td>
                               
                            </tr>
                            }
                      
                    </table>

 

页面jquery代码:

 $("#ckall").live('click', function () {
                var vl = $(this).attr("checked") == "checked";
                $("input[name='ckitem']").attr("checked", vl);
            });
            $("#shenhe").click(function () {
                if ($("input[name='ckitem']:checked").length == 0) {

                    alert("请选中数据");
                    return false;
                } else {
                    var ids = new Array();
                    $("input[name='ckitem']:checked").each(function () {
                        var vl = $(this).val();
                        ids.push(vl);
                    });
                    $.post("/SuperMarket/ShenHe", { ids: ids.toString() })  //要处理的函数
                .success(function () { alert("批量审核通过!"); window.location.reload(); })
                .error(function () { alert("处理出错", "提示"); window.location.reload(); });
                }
                //window.location.reload();

            });

posted on 2012-12-13 15:54  梦若夕阳海  阅读(628)  评论(0编辑  收藏  举报