• ExtJs 4 grid 批量删除 获取选中行ID



    重点是标记出来的地方,不解释。

                itemId: 'btnRemove',
                text: '删除用户',
                iconCls: 'delete',
                disabled: true,
                handler: function () {
                    
                    var selModel = grid.getSelectionModel();
                    if (selModel.hasSelection()) {
                        Ext.Msg.confirm("警告", "确定要删除吗?", function (button) {
                            if (button == "yes") {
                                var selected = selModel.getSelection();
                                var Ids = []; //要删除的id
                                Ext.each(selected, function (item) {
                                    Ids.push(item.data.Id);
                                })
                              //  alert(Ids);

                            }
                        });
                    }
                    else {
                        Ext.Msg.alert("错误", "没有任何行被选中,无法进行删除操作!");
                    }
                }

    ExtJs4 Ajax 删除操作

    //************批量删除管理员操作****************//
        function Delete_Data(ids) {
            Ext.MessageBox.show({
                msg: 
    '正在请求数据, 请稍侯',
                progressText: 
    '正在请求数据',
                 
    300,
                wait: 
    true,
                waitConfig: { interval: 
    10 }
            });
           
    // Ext.Ajax.defaultPostHeader = 'FTchinaMVC/json'; //仅传递ids数组即可,无需转换为json
            Ext.Ajax.request({
                url: 
    '/master/DeleteModels',
                method: 
    "post",
                success: 
    function (response, opts) {
                    Ext.MessageBox.hide();
                    
    if (response.responseText) {
                        store.load();
                        Ext.Msg.alert(
    '系统提示'"删除成功");
                    } 
    else {
                        Ext.Msg.alert(
    "系统提示"'删除失败');
                    }
                },
                failure: 
    function () {
                    Ext.Msg.alert(
    '系统提示''系统出错!');
                },
                params: {ids:ids}
            });
        }

    增加一个自定义的Action,接受传递过来的Ids

            [HttpPost]
            
    public ActionResult DeleteModels(string[] ids)
            {
                
    foreach (string id in ids)
                {
                    Master master 
    = db.Master.Find(int.Parse(id));
                    db.Master.Remove(master);
                    db.SaveChanges();
                }
                
    return this.JsonFormat(new ExtResult { success = true });
            }
  • 相关阅读:
    [Algorithm] DP Min Number of Jumps
    [React] Error boundary
    [Recoil] Optimising API Calls
    [Recoil] Intermediate Selectors
    [Typescript] Tips: Create autocomplete helper which allows for arbitrary values
    一文搞懂springboot启动原理
    [springboot]springboot启动流程[通俗易懂]
    springboot启动原理总结_Springboot启动流程
    springboot启动流程概述_简述app启动的主要流程
    SpringBoot启动原理
  • 原文地址:https://www.cnblogs.com/zihuxinyu/p/2073551.html
Copyright © 2020-2023  润新知