javascript - ExtJS Cell Selection Model with PivotGrid Doesn't Work -
i'm trying change selectionmodel of pivotgrid , isn't working. here code. can tell doing wrong.
i need use cellselectionmodel want drill down , need top , left axis intersection points.
i have tried 'cellclick' event in extjs 3.3 api no luck. selection model other default rowselectionmodel working?
var pivotaccumgrid = new ext.grid.pivotgrid({ store : my_store, aggregator: 'count', measure : 'my_field', sm: new ext.grid.cellselectionmodel({ //i have tried selmodel key listeners: { cellselect: function(sm,row,col) { ext.msg.alert('click','got click!'); } } }), topaxis: [ {dataindex: 'top_field'},{dataindex: 'top_field2'} ], leftaxis: [ {dataindex: 'left_field', width: 80} ], });
this quick fix introduces new property meta
in pivotgridview
can later used out cell indices. of code isn't different, introduction of meta.id
in renderrows
, splitting of meta.id
in getcellindex
.
ext.override(ext.grid.pivotgridview, { renderrows : function(startrow, endrow) { var grid = this.grid, rows = grid.extractdata(), rowcount = rows.length, templates = this.templates, renderer = grid.renderer, hasrenderer = typeof renderer == 'function', getcellcls = this.getcellcls, hasgetcellcls = typeof getcellcls == 'function', celltemplate = templates.cell, rowtemplate = templates.row, rowbuffer = [], meta = {}, tstyle = 'width:' + this.getgridinnerwidth() + 'px;', colbuffer, column, i; startrow = startrow || 0; endrow = ext.isdefined(endrow) ? endrow : rowcount - 1; (i = 0; < rowcount; i++) { row = rows[i]; colcount = row.length; colbuffer = []; rowindex = startrow + i; //build each column's html (j = 0; j < colcount; j++) { cell = row[j]; meta.id = + '-' + j; meta.css = j === 0 ? 'x-grid3-cell-first ' : (j == (colcount - 1) ? 'x-grid3-cell-last ' : ''); meta.attr = meta.cellattr = ''; meta.value = cell; if (ext.isempty(meta.value)) { meta.value = ' '; } if (hasrenderer) { meta.value = renderer(meta.value); } if (hasgetcellcls) { meta.css += getcellcls(meta.value) + ' '; } colbuffer[colbuffer.length] = celltemplate.apply(meta); } rowbuffer[rowbuffer.length] = rowtemplate.apply({ tstyle: tstyle, cols : colcount, cells : colbuffer.join(""), alt : '' }); } return rowbuffer.join(""); }, getcellindex : function(el) { if (el) { var match = el.classname.match(this.colre), data; if (match && (data = match[1])) { return parseint(data.split('-')[1], 10); } } return false; } });
Comments
Post a Comment