亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript中使用sencha gridpanel 編輯單元格、改變單元格顏色

 更新時(shí)間:2015年11月26日 17:17:04   投稿:mrr  
ExtJS中的表格功能非常強(qiáng)大,包括了排序、緩存、拖動(dòng)、隱藏某一列、自動(dòng)顯示行號(hào)、列匯總、單元格編輯等實(shí)用功能,通過本篇文章給大家介紹JavaScript中使用sencha gridpanel 編輯單元、改變單元格顏色,感興趣的朋友一起學(xué)習(xí)

表格GridPanel概述

      ExtJS中的表格功能非常強(qiáng)大,包括了排序、緩存、拖動(dòng)、隱藏某一列、自動(dòng)顯示行號(hào)、列匯總、單元格編輯等實(shí)用功能。

  表格由類Ext.grid.GridPanel定義,繼承自Panel,其xtype為grid。ExtJS中,表格Grid必須包含列定義信息,并指定表格的數(shù)據(jù)存儲(chǔ)器Store。表格的列信息由類Ext.grid.Column(以前是由Ext.grid.ColumnModel定義)、而表格的數(shù)據(jù)存儲(chǔ)器由Ext.data.Store定義,數(shù)據(jù)存儲(chǔ)器根據(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, //點(diǎn)擊單元格編輯
listeners: {
beforeedit: {
fn: me.onCellEditingBeforeEdit,
scope: me
},
validateedit: {
fn: me.onCellEditingValidateedit,
scope: me
}
}
})
]
}
onCellEditingBeforeEdit: function(editor, e, eOpts) {//動(dòng)態(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) //驗(yàn)證邏輯
{
e.cancel=true; //取消
e.record.data[e.field] = e.value;
}
e.record.commit();
}

下面一段代碼是關(guān)于sencha gridpanel改變單元格顏色

標(biāo)題列包含 審核通過則綠色,包含拒絕為紅色:

{
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: '標(biāo)題'
}

相關(guān)文章

最新評(píng)論