最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2015年11月26日 17:17:04   投稿:mrr  
ExtJS中的表格功能非常強(qiáng)大,包括了排序、緩存、拖動(dòng)、隱藏某一列、自動(dòng)顯示行號(hào)、列匯總、單元格編輯等實(shí)用功能,通過(guò)本篇文章給大家介紹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等。

下面通過(guò)一段代碼給大家介紹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(); //提交,不提交無(wú)效
}
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)題列包含 審核通過(guò)則綠色,包含拒絕為紅色:

{
xtype: 'gridcolumn',
renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
metaData.tdAttr = 'data-qtip="'+record.data.Content+'"';

if(record.data.Content.indexOf('審核通過(guò)')!=-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)論

乌恰县| 新源县| 温州市| 友谊县| 鄂温| 青海省| 武强县| 六安市| 青河县| 阿拉善左旗| 莱西市| 定兴县| 辉南县| 枣庄市| 延津县| 青川县| 西贡区| 沾化县| 桃江县| 靖州| 禹城市| 十堰市| 广汉市| 资中县| 浦县| 岳池县| 九寨沟县| 拉萨市| 乌兰察布市| 安徽省| 金门县| 巴彦淖尔市| 朝阳市| 青铜峡市| 砚山县| 南漳县| 喀喇沁旗| 肇州县| 波密县| 泰和县| 富阳市|