关于gridpanel带checkbox的实例

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<script type="text/javascript">
  Ext.QuickTips.init();
    (function () {

        var DeptStore = new Ext.data.JsonStore({
            root: 'Table',
            totalProperty: 'totalCount',
            baseParams: { start: 0, limit: 25, WardId: null },
            fields:
                    [
                      'dep_code', 'dep_name'
                    ],
            proxy: new Ext.data.HttpProxy({
                url: "../Location/GetDepartment"
            })
        });
        WardDepartmentWin = Ext.extend(Ext.Window, {
            id: 'DeptWardWin',
            title: '科室所属的病区',
            bqid: "",
            layout:"border",
            width: 600,
            height: 300,
            plain: true,
            maximizable: false,
            minimizable: true,
            closable: true,
            draggable: true,
            resizable: false,
            modal: true,
            closeAction: 'close',
            bodyStyle: 'padding:5px;',
            listeners: { "afterrender": function () {
                DeptStore.load();
            }},
            initComponent: function () {

                //通过病区获取该病区的所有科室
                var sm = new Ext.grid.CheckboxSelectionModel();
                this.items = [
                {
                          xtype:'grid',
                          id:'DeptGrid',
                          layout: 'form',
                          region:"center",
                          width: 800,
                          height: 300,
                          title: '请选择病区所关联的科室',
                          loadMask: true,
                          trackMouseOver: true,
                          sm: sm,
                          border: false,
                          store: DeptStore,
                          bbar: new Ext.PagingToolbar({
                              pageSize: 25,
                              store: DeptStore,
                              displayInfo: true,
                              displayMsg: '结果{0}-{1}到{2}',
                              emptyMsg: '没有可显示的结果'
                          }),
                          columns:
                          [
                             sm,
                             {
                                 header: 'ID',
                                 sortable: true,
                                 resizable: true,
                                 hidden: true,
                                 dataIndex: "dep_code",
                                 width: 150
                             },
                             {
                                 header: '科室名称',
                                 sortable: true,
                                 resizable: true,
                                 dataIndex: "dep_name",
                                 width: 300
                             }
                          ]
                }];
                this.buttons = [{
                    text: '保存',
                    iconCls: "icon-tick",
                    id: "savedept",
                    listeners: { "click": function () {
                        var s = Ext.getCmp("DeptGrid").getSelectionModel().getSelections();
                        var str = "";
                        if (s.length >= 0) {
                            for (var i = 0; i < s.length; i++) {
                                str = str + s[i].get('dep_code') + ",";
                            }
                        }
                        var bqid = Ext.getCmp("DeptWardWin").bqid;
                        str=str.substring(0,str.length-1);
                    
                        var requestConfig = {
                            url: '../Location/AddWardDepart',
                            params: { bqid: bqid, deptcode: str },
                            callback: function (options, success, response) {
                                if (success) {
                                    var info = Ext.decode(response.responseText);
                                    if (info._result == 'success') {
                                        Ext.Msg.alert('消息', '添加成功!');
                                        Ext.getCmp("DeptWardWin").close();
                                        return;
                                    }
                                    else {
                                        Ext.Msg.alert('消息', '添加失败!');
                                    }
                                }
                            }
                        }
                        Ext.Ajax.request(requestConfig);
                    
                    }
                    }
                }, {
                    text: "取消",
                    iconCls: "icon-cross",
                    handler: function () {
                        this.ownerCt.ownerCt.close();
                    }
                }]
                WardDepartmentWin.superclass.initComponent.call(this);
            }
        });

        AddWard = Ext.extend(Ext.Window, {
            id: 'MyWin',
            title: "添加病区",
            width: 900,
            height: 240,
            //hosp: "",
            isadd: true,
            plain: true,
            labelWidth: 100,
            maximizable: false,
            minimizable: true,
            closable: true,
            draggable: true,
            resizable: false,
            modal: true,
            closeAction: 'close',
            bodyStyle: 'padding:5px;',
            initComponent: function () {
                this.items = [
                   new Ext.form.FormPanel({
                       ref: "form",
                       border: false,
                       frame: true,
                       header: false,
                       defaultType: "textfield",
                       defaults: {
                           anchor: "80%"
                       },
                       items: [
                          {
                              fieldLabel: '病区名称',
                              id: 'bqmc',
                              name: 'bqmc'

                          }
                          ,
                          {
                              fieldLabel: '拼音码',
                              name: 'py',
                              id: 'pycode',
                              labelWidth: 130
                          },
                          {
                              fieldLabel: '五笔码',
                              name: 'wb',
                              id: 'wbcode',
                              labelWidth: 130
                          },
                         {
                             fieldLabel: '床位数',
                             name: 'cws',
                             id: 'bednum',
                             labelWidth: '60'
                         }
                        ]
                   })
                ],
                 this.buttons = [{ text: '确定',
                     iconCls: "icon-tick",
                     id: 'addLocation',
                     listeners: { "click": function () {
                         var bqmc = Ext.getCmp("bqmc").getValue();
                         var py = Ext.getCmp("pycode").getValue();
                         var wb = Ext.getCmp("wbcode").getValue();
                         var TOTALBED = Ext.getCmp("bednum").getValue();
                         var requestConfig = {
                             url: '../Location/AddWard',
                             params: { bqmc: bqmc, py: py, wb: wb, TOTALBED: TOTALBED },
                             callback: function (options, success, response) {
                                 if (success) {
                                     var info = Ext.decode(response.responseText);
                                     if (info._result == 'success') {
                                         Ext.Msg.alert('消息', '添加成功!');
                                         Ext.getCmp("MyWin").close();
                                         Ext.getCmp("grdWard").store.reload();
                                         return;
                                     }
                                     else {
                                         Ext.Msg.alert('消息', '添加失败!');
                                     }
                                 }
                             }
                         }
                         Ext.Ajax.request(requestConfig);

                     }
                     }
                 },
                 {
                     text: '取消',
                     iconCls: "icon-cross",
                     handler: function () { this.ownerCt.ownerCt.close(); }
                 }]
                AddWard.superclass.initComponent.call(this);
            }
        });

        WardListPanel = Ext.extend(Ext.Panel, {
            xtype: "panel",
            width: 551,
            height: 230,
            layout: "border",
            initComponent: function () {
                //获得医院的所有病区
                var WardStore = new Ext.data.JsonStore({
                    root: 'Table',
                    totalProperty: 'totalCount',
                    baseParams: { start: 0, limit: 25, searchType: null, name: null },
                    fields:
                    [
                      'ID', 'NAME', 'TOTALBED', 'HOSNO'
                    ],
                    proxy: new Ext.data.HttpProxy({
                        url: "../Location/GetHospWard"
                    })
                });
               var DeptWardStore=new Ext.data.JsonStore({
                   root: 'Table',
                   totalProperty: 'totalCount',
                   baseParams: { start: 0, limit: 25, searchType: null, name: null,wardid:null },
                   fields:
                    [
                      'dep_code', 'dep_name'
                    ],
                   proxy: new Ext.data.HttpProxy({
                       url: "../Location/GetWard_departments"
                   })
               });
                WardStore.load();
                var SourceData = [{ id: 0, display: "拼音" }, { id: 1, display: "五笔" }, { id: 2, display: "汉字"}]
                var sm = new Ext.grid.CheckboxSelectionModel({
                    singleSelect: false,
                    listeners: {
                        rowselect: function (sm, rowIndex, rec) {

                        },
                        rowdeselect: function (sm, rowIndex, rec) {

                        }
                    }
                });
                var SearchStore = new Ext.data.JsonStore({
                    data: SourceData,
                    fields: ['id', 'display']
                });
                this.items = [
                  {
                      id: "grdWard",
                      xtype: "grid",
                      title: "病区列表",
                      //height: 120,
                      region: "center",
                      loadMask: true,
                      trackMouseOver: true,
                      border: false,
                      sm: sm,
                      store: WardStore,
                      bbar: new Ext.PagingToolbar({
                          pageSize: 25,
                          store: WardStore,
                          displayInfo: true,
                          displayMsg: '数据结果 {0} - {1} 到 {2}',
                          emptyMsg: "没有可显示的结果"
                      }),
                      listeners: { "rowdblclick": function (d,v) {
                          var wardid=d.store.data.items[v].data.ID;
                          var frequency_store=Ext.getCmp("grdDeptWard").getStore();
                          frequency_store.baseParams.wardid=wardid;
                          frequency_store.load();
                      }},
                      tbar: new Ext.Toolbar([
                             {
                                 text: '添加病区',
                                 iconCls: 'icon-pageadd',
                                 handler: function () {
                                     //new AddWard();
                                     new AddWard().show();
                                 }
                             },
                             {
                                text:'取消病区',
                                iconCls:'icon-pagedelete',
                                handler:function(){
                                    var record = Ext.getCmp("grdWard").getSelectionModel().getSelected();
                                    if(record && record.data)
                                    {
                                       var id=record.data.ID;
                                       var requestConfig = {
                                           url: '../Location/CancelWard',
                                           params: { wardid: id },
                                           callback: function (options, success, response) {
                                               if (success) {
                                                   var info = Ext.decode(response.responseText);
                                                   if (info._result == 'success') {
                                                       Ext.Msg.alert('消息', '取消成功!');
                                                       Ext.getCmp("grdWard").store.reload();
                                                       return;
                                                   }
                                                   else {
                                                       Ext.Msg.alert('消息', '取消失败!');
                                                   }
                                               }
                                           }
                                       }
                                       Ext.Ajax.request(requestConfig);
                                    }
                                    else {
                                         Ext.Msg.alert("消息", "请先选择一条数据");
                                    }
                                }
                             },
                             {
                                 text: '关联科室',
                                 //disabled: datas == 1 ? true : false,
                                 iconCls: 'icon-pageadd',
                                 handler: function () {
                                     var record = Ext.getCmp("grdWard").getSelectionModel().getSelected();

                                     if (record && record.data) {
                                         var id = record.data.ID; //病区ID
                                       
                                         new WardDepartmentWin({ bqid: id }).show();
                                     }
                                     else {
                                         Ext.Msg.alert("消息", "请先选择一条数据");
                                     }
                                 }
                             },
                             "-",
                            { xtype: 'label', text: '区域名称' }, { xtype: 'textfield', id: 'txtterm', width: 80 },
                             "-",
                            {
                                text: '区域搜索', iconCls: 'icon-search', handler: function () {
                                    //var termsearch = Ext.getCmp("txtterm").getValue();
                                    alert('搜索');
                                }
                            },
                          '-'
                          ]),
                      columns: [
                              {
                                  header: "编号",
                                  sortable: true,
                                  resizable: true,
                                  hidden: true,
                                  dataIndex: "ID",
                                  width: 150
                              },
                             {
                                 header: "区域名称",
                                 sortable: true,
                                 resizable: true,
                                 dataIndex: "NAME",
                                 width: 280
                             },
                             {
                                 header: "床位数",
                                 sortable: true,
                                 resizable: true,
                                 dataIndex: "TOTALBED",
                                 width: 100
                             },
                              {
                                  header: "医院编码",
                                  sortable: true,
                                  resizable: true,
                                  dataIndex: "HOSNO",
                                  width: 80
                              }
                        ]
                  },
                      {
                          id: "grdDeptWard",
                          xtype: "grid",
                          title: "病区科室",
                          height: 250,
                          region: "south",
                          loadMask: true,
                          trackMouseOver: true,
                          border: false,
                          store: DeptWardStore,
                          bbar: new Ext.PagingToolbar({
                              pageSize: 25,
                              store: DeptWardStore,
                              displayInfo: true,
                              displayMsg: '结果 {0} - {1} 到 {2}',
                              emptyMsg: "没有可显示的结果"
                          }),
                          tbar: new Ext.Toolbar([
                           {
                               text: '取消科室',
                               id: 'ProcessSnomedCTCN',
                               iconCls: 'icon-pageedit',
                               handler: function () {
                                   var record = Ext.getCmp("grdDeptWard").getSelectionModel().getSelected();

                                   if (record && record.data) {
                                       //删除病区所关联的科室
                                       var dep_code=record.data.dep_code;
                                       var requestConfig = {
                                           url: '../Location/CancelDepartment',
                                           params: { dep_code:dep_code },
                                           callback: function (options, success, response) {
                                               if (success) {
                                                   var info = Ext.decode(response.responseText);
                                                   if (info._result == 'success') {
                                                       Ext.Msg.alert('消息', '取消成功!');
                                                       Ext.getCmp("grdDeptWard").store.reload();
                                                       return;
                                                   }
                                                   else {
                                                       Ext.Msg.alert('消息', '取消失败!');
                                                   }
                                               }
                                           }
                                       }
                                       Ext.Ajax.request(requestConfig);
                                   }
                                   else {
                                       Ext.Msg.alert("消息", "请先选择一条数据");
                                   }
                               }
                           },
                               { xtype: 'label', text: '搜索方式:' },
                                { xtype: 'combo', id: 'cbsource', //typeAhead: true,
                                    triggerAction: 'all',
                                    mode: 'local',
                                    emptyText: '--请选择--',
                                    store: SearchStore,
                                    value: '',
                                    width: 130,
                                    valueField: 'id',
                                    displayField: 'display',
                                    selectOnFocus: true
                                }, "-",
                                {
                                    xtype: 'label', text: '搜索名称:'
                                },
                               {
                                   xtype: 'textfield', id: 'searchname', width: 200
                               },
                              {
                                  text: '搜索', iconCls: 'icon-search', handler: function () {
                                      //过滤科室数据
                                  }
                              }
                            ]),
                          columns: [
                              {
                                  header: "编号",
                                  sortable: true,
                                  resizable: true,
                                  dataIndex: "dep_code",
                                  width: 150
                              },
                               {
                                   header: "名称",
                                   sortable: true,
                                   resizable: true,
                                   dataIndex: "dep_name",
                                   width: 280
                               }
                         ]
                      }
          ]
                WardListPanel.superclass.initComponent.call(this);
            }
        })

        return WardListPanel;
    })();
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值