關於extjs4的行列操作

剛開始用extjs4.。。。。。。各種糾結與不熟悉,,,,,個人覺得extjs功能強大,但靈活性比jQuery+jsp差,而且渲染速度也慢一些。

哎。。。不如正題吧。。。。

按照下面的方法可以操作某行某列的任何數據

var arrs  = [];     //聲明的全局變量       一直以來全局變量都是好東西,這個思想不能忘記。

columns.push(

            new Ext.grid.RowNumberer(),//行數
            {
                text: '名稱',width: 200, searchType : 'string',
                sortable: false,
                menuDisabled:true,

                renderer:function(value,metaData,record){

                                          value-------指定的爲該列的值

                                          metaData---------指定的爲你的元數據,總是裏面很多東西,啥都有,這玩意複雜

                                          record--------------指定的爲你的對象的所有值

                              arrs.push(record);    //把結果放入到全局變量裏面
                              return value;  //這裏必須返回value,如果返回record你的頁面將顯示的爲object object
                          },

                dataIndex: 'cName'
            },{
                text : '狀態',width : 60, dataIndex:'status',  
                menuDisabled:true,
                searchType : 'number',
                renderer: function(val, u,r, rowIndex, columnIndex, s){
                    return renders.translateIsStatus(val, u,r, rowIndex, columnIndex - 1, s);
                },
                align : 'center'
            },{
                text : '內容', width : 200, dataIndex:'comment',  
                menuDisabled:true,
                searchType : 'string',
                align : 'center'

            },

              {

               text:'操作',  
               menuDisabled: true,  
               sortable: false,  
               align:'center',  
               xtype: 'actioncolumn',  
               width: 60,  
               items: [{  
                   iconCls   :'x-add-icon',  
                   id: 'upArraw',  
                   tooltip: '增加',  
                   handler: function() {
                        //......此處寫相關業務邏輯
                   }  
               },{  
                   iconCls   :'x-del-icon',
                   id: 'delArraw',
                   tooltip: '刪除',

                   handler: function(grid, rowIdx, colIdx) { 

                       var sa = arrs[rowIdx].id;
                       var arry = sa.split("-");
                       var arryId = arry[1];
                      //......此處寫相關業務邏輯
                   }  
               },{  
                   iconCls   :'update',  
                   tooltip: '修改',  
                   id: 'downArraw',  

                   handler: function(grid, rowIdx, colIdx) {  

                     //rowIndex,colIndex均從0開始  

                    grid---------------指定你的grid

                     rowIndex---------行數

                     colIndex-----------所在的列數

                  

                       var sa = arrs[rowIdx].id;     //這裏得到的sa的值將爲 xxx.xxx.xxx-value          value就是說需要的值。
                       var arry = sa.split("-");  //在這裏進行截取取得你想要的value值
                       var arryId = arry[1];
                       //......此處寫相關業務邏輯
//                        alert(rowIdx+"---------"+colIdx);
                   }  
               }]  

            }

          該操作說出來的效果圖爲

            

        );

其實現在我還在糾結一個問題

{
                text : '內容', width : 200, dataIndex:'comment',  
                menuDisabled:true,
                searchType : 'string',

                hidden :  true,
                align : 'center'
            }

這樣的話怎麼得到該行該列的值,,,hidden爲false時,很容易就得到了。

這難道就是extjs4的專門這樣設置的嗎?不讓獲取隱藏列的值???如有大拿,不吝賜教。


發佈了36 篇原創文章 · 獲贊 6 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章