效果:

1334627719_5300.png

1334627725_8184.png

户型图列显示的图片实际上就是一个超链接。

添加一个Button分2个步骤:

1.在列头中定义超链接列或者Button列的HTML代码,也就是Render

2.添加该Button的事件处理函数。其中,gridPanel应作为参数传入该函数。

应该在gridPanel初始化时定义:

(1)cellClick的listener:cellClick

(2)cellClick事件的处理函数:onCellClick

列头定义的代码如下:

var cm = new Ext.grid.ColumnModel([

sm,

new Ext.grid.RowNumberer(), //自动添加行号

{

header: "房间编号",

dataIndex: "RoomNumber",

//可以进行排序

sortable: true

}, {

header: "户型结构",

dataIndex: "huxingjiegou",

//可以进行排序

isHidden: true,

sortable: true

}, {

header: "面积(M²)",

dataIndex: "area",

//可以进行排序

sortable: true

}, {

header: "单价(元/M²)",

dataIndex: "singlePrice",

//可以进行排序

sortable: true

// editor: new Ext.grid.GridEditor(new Ext.form.NumberField({

// allowBlank: false

// }))

}, {

header: "总价(元)",

dataIndex: "totalPrice",

//可以进行排序

sortable: true

}, {

header: "面积(M²)",

dataIndex: "mianjiCC",

//可以进行排序

sortable: true

}, {

header: "单价(元/M²)",

dataIndex: "priceCCS",

//可以进行排序

sortable: true

// editor: new Ext.grid.GridEditor(new Ext.form.NumberField({

// allowBlank: false

// }))

}, {

header: "总价(元)",

dataIndex: "totalPriceCCS",

//可以进行排序

sortable: true

}, {

header: "面积(M²)",

dataIndex: "mianjiCK",

//可以进行排序

sortable: true

}, {

// header: "单价(元/M²)",

header: "总价(元/M²)",

dataIndex: "priceCK",

//可以进行排序

sortable: true

// editor: new Ext.grid.GridEditor(new Ext.form.NumberField({

// allowBlank: false

// }))

},

{

header: "",

dataIndex: "totalPriceALL",

//可以进行排序

sortable: true

},

{

header: "户型图",

tooltip: "户型图",

width: 120,

locked: true,

menuDisabled: true,

sortable: false,

dataIndex: "huxingPic",

renderer: function (data, metadata, record, rowIndex, columnIndex, store) {

var picture = store.getAt(rowIndex).get('huxingPic');

return '' + ''%20+%20picture%20+%20'';

}

},

{

header: "订购",

renderer: function (value, meta, record) {

var formatStr = "订购";

var resultStr = String.format(formatStr);

return "

" + resultStr + "
";

} .createDelegate(this),

css: "text-align:center;",

// width: 30,

sortable: false

}

]);

注意超链接为'',而按钮为return "

更多推荐