JavaScript中使用sencha gridpanel 編輯單元格、改變單元格顏色
表格GridPanel概述
ExtJS中的表格功能非常強大,包括了排序、緩存、拖動、隱藏某一列、自動顯示行號、列匯總、單元格編輯等實用功能。
表格由類Ext.grid.GridPanel定義,繼承自Panel,其xtype為grid。ExtJS中,表格Grid必須包含列定義信息,并指定表格的數(shù)據(jù)存儲器Store。表格的列信息由類Ext.grid.Column(以前是由Ext.grid.ColumnModel定義)、而表格的數(shù)據(jù)存儲器由Ext.data.Store定義,數(shù)據(jù)存儲器根據(jù)解析的數(shù)據(jù)不同分為JsonStore、SimpleStroe、GroupingStore等。
下面通過一段代碼給大家介紹sencha gridpanel 編輯單元,具體代碼如下所示:
{ xtype: 'gridpanel', region: 'north', height: 150, title: 'My Grid Panel', store: 'A_Test_Store', columns: [ { xtype: 'gridcolumn', dataIndex: 'Name', text: 'Name', editor: { xtype: 'textfield' } }, { xtype: 'gridcolumn', dataIndex: 'Content', text: 'Content' }, { xtype: 'gridcolumn', dataIndex: 'Time', text: 'Time' } ], plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, //點擊單元格編輯 listeners: { beforeedit: { fn: me.onCellEditingBeforeEdit, scope: me }, validateedit: { fn: me.onCellEditingValidateedit, scope: me } } }) ] } onCellEditingBeforeEdit: function(editor, e, eOpts) {//動態(tài)賦值用.正常情況下不需要該事件. e.record.data[e.field]= "my test"; e.value="my test"; e.record.commit(); //提交,不提交無效 } onCellEditingValidateedit: function(editor, e, eOpts) { if(e.row==1) //驗證邏輯 { e.cancel=true; //取消 e.record.data[e.field] = e.value; } e.record.commit(); }
下面一段代碼是關(guān)于sencha gridpanel改變單元格顏色
標題列包含 審核通過則綠色,包含拒絕為紅色:
{ xtype: 'gridcolumn', renderer: function(value, metaData, record, rowIndex, colIndex, store, view) { metaData.tdAttr = 'data-qtip="'+record.data.Content+'"'; if(record.data.Content.indexOf('審核通過')!=-1) { metaData.style="color:green"; } else if(record.data.Content.indexOf('拒絕')!=-1) { metaData.style="color:red"; } return value; } , width: '*', dataIndex: 'Title', text: '標題' }
- js+css繪制顏色動態(tài)變化的圈中圈效果
- 基于javascript實現(xiàn)隨機顏色變化效果
- js點擊列表文字對應(yīng)該行顯示背景顏色的實現(xiàn)代碼
- JavaScript取得WEB安全顏色列表的方法
- javascript實現(xiàn)rgb顏色轉(zhuǎn)換成16進制格式
- javascript+css3 實現(xiàn)動態(tài)按鈕菜單特效
- APP中javascript+css3實現(xiàn)下拉刷新效果
- js 獲取和設(shè)置css3 屬性值的實現(xiàn)方法
- js 顏色選擇器(兼容firefox)
- JavaScript獲取圖片像素顏色并轉(zhuǎn)換為box-shadow顯示
相關(guān)文章
wangEditor編輯器失去焦點后仍然可以在原位置插入圖片分析
本文給大家?guī)淼氖且豢罘浅2诲e的富文本編輯器WangEditor,他最大的特點是它在ie6,7,8上都可以做到失去焦點后仍然可以在原位置插入圖片,而且代碼量很少,下面我們就來分析下他是如何實現(xiàn)的呢2015-05-05JavaScript+html5 canvas實現(xiàn)圖片破碎重組動畫特效
這篇文章主要介紹了JavaScript+html5 canvas實現(xiàn)破碎重組的視頻特效,感興趣的小伙伴們可以參考一下2016-02-02CocosCreator骨骼動畫之龍骨DragonBones
這篇文章主要介紹了怎么在CocosCreator中使用骨骼動畫龍骨DragonBones,對骨骼動畫感興趣的同學(xué),可以試一下2021-04-04JavaScript基礎(chǔ)之this和箭頭函數(shù)詳析
這篇文章主要給大家介紹了關(guān)于JavaScript基礎(chǔ)之this和箭頭函數(shù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學(xué)習或者使用JavaScript具有一定的參考學(xué)習價值,需要的朋友們下面來一起學(xué)習學(xué)習吧2019-09-09JS實現(xiàn)點擊圖片在當前頁面放大并可關(guān)閉的漂亮效果
點擊圖片在當前頁面放大的漂亮效果實現(xiàn)方法有很多,在本文將為大家介紹下使用Lightbox JS是如何實現(xiàn)的,感興趣的朋友不要錯過2013-10-10List the Codec Files on a Computer
List the Codec Files on a Computer...2007-06-06