剛開始用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--------------指定的爲你的對象的所有值
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 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 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的專門這樣設置的嗎?不讓獲取隱藏列的值???如有大拿,不吝賜教。