使用时注意参数顺序位置:
1. renderer:function (value, cellmeta, record, rowIndex, columnIndex, store) {?
?value :这个单元格的值;
cellmeta.cellId: 这个单元格的配置
cellmeta.id:? id
record :这个单元格对应的record
rowIndex 这是第几行
store 这个表格对应的Ext.data.Store
}
?2.? function renderDescn(value, cellmeta, record, rowIndex, columnIndex, store) {???????
??????? var str = "<input type='button' value='查看详细信息' onclick='alert(\"" +
??????????? "这个单元格的值是:" + value + "\\n" +
??????????? "这个单元格的配置是:{cellId:" + cellmeta.cellId + ",id:" + cellmeta.id + ",css:" + cellmeta.css + "}\\n" +
??????????? "这个单元格对应行的record是:" + record + ",一行的数据都在里边\\n" +
??????????? "这是第" + rowIndex + "行\\n" +
??????????? "这是第" + columnIndex + "列\\n" +
??????????? "这个表格对应的Ext.data.Store在这里:" + store + ",随便用吧。" +
??????????? "\")'>";
??????? return str;
??? }
使用实例:
??? //--------------------------------------------------列选择模式
??? var sm = new Ext.grid.CheckboxSelectionModel({
??????? dataIndex: "openroomid"
??? });
??? //--------------------------------------------------列头
??? var cm = new Ext.grid.ColumnModel([
sm, {
?? header: "开房ID",
?? dataIndex: "openroomid",
?? tooltip: "开房唯一标识ID",
?? //列不可操作
?? //menuDisabled:true,
?? //可以进行排序
?? sortable: true
}, {
?? header: "房间号",
?? tooltip: "客人所住房间编号",
?? dataIndex: "roomid",
?? sortable: true,
?? renderer: function(value) {
?????? return "<a herf='Default.aspx' target='_blank'>" + value + "</a>"
?? }
}, {
?? header: "所付定金",
?? tooltip: "客人所付定金",
?? dataIndex: "guestmoney",
?? sortable: true,
?? renderer: function(value) {?? //将数字转换为整数
?????? if (value != null && value != "") {
?????????? var a, b, c, i
?????????? a = value.toString();
?????????? b = a.indexOf('.');
?????????? c = a.length;
?????????? if (b != -1)
?????????????? a = a.substring(0, b);
?????? }
?????? if (b == -1) {
?????????? a = a + ".";
?????????? for (i = 1; i <= c; i++)
?????????????? a = a - "0";
?????? }
?????? else {
?????????? a = a.substring(0, b + c + 1);
?????????? for (i = c; i <= b + c; i++) {
?????????????? a = a - "0";
?????????? }
?????? }
?????? return '<span style="color:red;"><b>' + String.format("<font color=red>¥{0}</font>", a) + '</b> 元</span>';
?? }
}, {
?? header: "开房日期",
?? tooltip: "开房具体日期",
?? dataIndex: "OpenTodayTime",
?? sortable: true
}]);
?
?
?
?