Grid[ cellclick、beforeedit、afteredit ]

cellclick: function(grid, rowIndex, columnIndex, e) {   

         var record = grid.getStore().getAt(rowIndex); // 獲得當前行的記錄

          varrecord = grid.getStore().getAt(rowIndex)).get(columnName);//獲得列表某行某列的值

         grid.store.getAt(rowIndex).set(columnName,value);//改變某行某列的值

         var fieldName = grid.getColumnModel().getDataIndex(columnIndex); //獲得列名(字段名)   

         var data = record.get(fieldName);//再從記錄中獲得這列的value   

         alert('你當前單擊的單元格的value:' + data);   

      }  

 

 

//添加明細或查看詳情彈出詳情編輯框

        grid.on('cellclick',function (thisgrid, rowIndex, columnIndex, e) { //獲得Ext.grid.EditorGridPanel編輯信息

            if (columnIndex == 9) {//公司賬單

                var id =thisgrid.getStore().getAt(rowIndex).data.id;

                Ext.MessageBox.show({

                    title: '提示',

                    msg: '確定要分配嗎?',

                    buttons: {ok: "分配", cancel: "取消" },

                    //buttons:Ext.MessageBox.OKCANCEL,

                    fn: showResult,

                    animEl: 'mb4',

                    icon:Ext.MessageBox.QUESTION

                });

 

            }

        });

 

        function showResult(btn) {

            if (btn == "ok") {

               Ext.MessageBox.alert("提醒", "分配成功");

                gridstore.reload();

            }

        };

 

 

 

 

 

viewConfig : {

                forceFit : true

            },

           listeners : {

               //單元格單擊事件

                'cellclick':function (grid, rowIndex, columnIndex, e){

                   if(columnIndex == 7){//合作信息

                        var row = grid.getStore().getAt(rowIndex).data;

                        var productType = row.ProductType;

                        var productID = row.ProductID;

                        var cur_row = JSLINQ(checkedData).First(function(item) { return item.ProductID == productID });

                        var spinfo = cur_row.CoopInfoId;

                        var CMID = parent.CMID;

                        var areaCode = Ext.getCmp('HZArea').getValue();

                       cur_productID = productID;

                       cur_rowIndex = rowIndex;

 

                        var url = '';

                        if(productType == '社保'){

                            url = "@Url.Action("Social", "CorpInfo")"+"?Spinfo=" + spinfo + "&CMID="+CMID+"&areaCode="+areaCode;

                        }else if(productType == '公積金'){

                            url = "@Url.Action("Fund", "CorpInfo")"+"?Spinfo=" + spinfo+ "&CMID="+CMID+"&areaCode="+areaCode;

                        }else if(productType == '商保'){

                            url = "@Url.Action("ShangBao", "CorpInfo")"+"?Spinfo=" + spinfo+ "&CMID="+CMID+"&areaCode="+areaCode;

                        }else if(productType == '週期性'){

                            url = "@Url.Action("Circle", "CorpInfo")"+"?Spinfo=" + spinfo;

                        }else if(productType == '一次性'){

                            url = "@Url.Action("Once", "CorpInfo")"+"?Spinfo=" + spinfo;

                       }

                        //彈出框

                        winCoorpinfo = new Ext.Window({

                            title        : '合作信息',

                            layout      : 'fit',

                            width       : 800,

                            height      : 380,

                            closeAction :'close',

                            plain       : true,

                            modal        : true,

                            items:[ new Ext.Panel({        

                                resizeTabs :true,

                                autoScroll : false,

                                html:'<iframe scrolling="auto"frameborder="0" width="100%" height="100%" src='+ url +'></iframe>'

                            })]

                       });

                       winCoorpinfo.show();

                   }

               },

               //編輯前,獲取編輯當前行

                'beforeedit':function (e){

                   SocialCalc = e.record.data.SocialCalc;

                   FundCalc = e.record.data.FundCalc;

                   cur_productTypeName = e.record.data.ProductType;

                   cur_productID = e.record.data.ProductID;

               },

               //編輯後,更新數據到全局數據集

                'afteredit':function (e){

                    var row = e.record.data;

                   if(e.field == 'CoopInfoId'){ //合作信息另作處理

                    }else{

                        //找出當前編輯的行

                        var cur_row = JSLINQ(checkedData)

                            .First(function(item){return item.ProductID == cur_productID;});

                       cur_row.RealCost = e.record.data.RealCost ;

                       cur_row.ExecuteCost = e.record.data.ExecuteCost ;

                       cur_row.ServiceCost = e.record.data.ServiceCost ;

                       cur_row.CalcuteTypeName = e.record.data.CalcuteTypeName ;

                       cur_row.IsBigBag = e.record.data.IsBigBag ;

                   }

               }

            },

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章