1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| Ext.define('PX.view.patent.MyInfPatentGrid', {
extend : 'Ext.grid.Panel',
alias : 'widget.myinfpatentgrid',
store : 'PX.store.patent.InfPatents',
region : 'center',
border : false,
collapsible : false,
animCollapse : false,
expandOnRender : true,
bodyStyle : 'border:0;',
plugins: {
ptype : 'bufferedrenderer',
pluginId : 'buffrenderplugin',
leadingBufferZone : 1, // The number of records to keep rendered below the visible area.
trailingBufferZone : 1 // The number of records to keep rendered above the visible area.
//,viewSize: 25
/*
// https://stackoverflow.com/questions/15660870/extjs-grid-renders-more-rows-than-specified-in-pagesize
// The trick was to set the buffer settings right in both the store and
// the grid's bufferedrenderer plugin, and overriding the onViewResize
// method of the plugin. The ViewSize property of the bufferedrenderer
// was getting computed based on the rowheight, which for some reason
// was always its default value of 21, and hence resulted in a ViewSize of 60,
// which is greater than the total number of records in the server (50).
// This resulted in all the rows being fetched right away.
// Once I overrode the viewsize property to 18, the viewsize changed
// correspondingly and now I have only 30 records fetched the first time.
// And on-demand loading works perfectly on scrolling as well :)
*/
//scrollToLoadBuffer : 10,
/*,onViewResize: function(view, width, height, oldWidth, oldHeight) {
// Only process first layout (the boxready event) or height resizes.
if (!oldHeight || height !== oldHeight) {
var me = this,
newViewSize,
scrollRange;
// View has rows, delete the rowHeight property to trigger a recalculation when scrollRange is calculated
if (view.all.getCount()) {
// We need to calculate the table size based upon the new viewport size and current row height
delete me.rowHeight;
}
// If no rows, continue to use the same rowHeight, and the refresh handler will call this again.
// Calculates scroll range. Also calculates rowHeight if we do not have an own rowHeight property.
// That will be the case if the view contains some rows.
scrollRange = me.getScrollHeight();
//newViewSize = Math.ceil(height / me.rowHeight) + me.trailingBufferZone + me.leadingBufferZone;
//console.log(height); // 634
//console.log(me.rowHeight); // 132
//console.log(me.trailingBufferZone); // 1
//console.log(me.leadingBufferZone); // 1
//console.log(Math.ceil(height / me.rowHeight) + me.trailingBufferZone + me.leadingBufferZone); // 7
newViewSize = 18;
me.viewSize = me.setViewSize(newViewSize);
me.stretchView(view, scrollRange);
}
}*/
},
bbar : [
{
xtype : 'tbtext',
itemId : 'tbipgselected',
text : 'No patent selected',
style : 'cursor:default;',
margin : '0 10 0 0'
}
],
initComponent: function() {
var me = this;
Ext.apply(me, {
selModel : Ext.create('Ext.selection.CheckboxModel',
{
//checkOnly : true //: on perd la multi-selection avec le shift :'(
mode: 'MULTI'
}
)
});
me.callParent(arguments);
me.getStore().on('beforeload', this.clearSelection, this);
},
clearSelection: function() {
this.getSelectionModel().deselectAll();
},
viewConfig : {
verticalScrollerType : 'paginggridscroller',
preserveScrollOnRefresh : false,
markDirty : false,
loadingText : 'Loading Patents, Please wait...',
listeners : {
itemmouseenter: function( view, record, item, rowIndex, e, eOpts ) {
// show the icon
if (Ext.isEmpty(record.get('com'))) {
//var cmp = Ext.select('#' + Ext.get(item).id + ' img.x-action-col-icon');
var cmp = Ext.select('#' + Ext.get(item).id +' [src~="16x16/messages.png"]');
cmp.removeCls('x-hide-display');
cmp.addCls('x-grid-center-icon');
}
if (record.get('flag')<0) {
var cmp = Ext.select('#' + Ext.get(item).id + ' img.x-action-col-icon');
cmp.removeCls('x-hide-display');
cmp.addCls('flagnb');
}
},
itemmouseleave: function( view, record, item, rowIndex, e, eOpts ) {
// hide the icon
if (Ext.isEmpty(record.get('com'))) {
//var cmp = Ext.select('#' + Ext.get(item).id + ' img.x-action-col-icon');
var cmp = Ext.select('#' + Ext.get(item).id +' [src~="16x16/messages.png"]');
cmp.removeCls('x-grid-center-icon');
cmp.addCls('x-hide-display');
}
if (record.get('flag')<0) {
//var cmp = Ext.select('#' + Ext.get(item).id + ' img.x-action-col-icon');
var cmp = Ext.select('#' + Ext.get(item).id +' [src~="16x16/flag/-1.png"]');
cmp.removeCls('x-grid-center-icon');
//cmp.removeCls('flagnb');
cmp.addCls('x-hide-display');
}
}
},
trackOver : false,
plugins : {
ddGroup : 'ddgridPatent',
pluginId : 'mydndgridPatent',
ptype : 'gridviewdragdrop',
dragText : 'Drop it on a Folder or a PatentList!',
enableDrop : false
}
}
}); |
Partager