@@ -237,6 +237,7 @@ if (!jQuery.fn.drag) {
237
237
secondaryHeaderRowHeight : 25 ,
238
238
syncColumnCellResize : false ,
239
239
enableAutoTooltips : true ,
240
+ toolTipMaxLength : null ,
240
241
formatterFactory : null ,
241
242
editorFactory : null ,
242
243
cellHighlightCssClass : "highlighted" ,
@@ -245,6 +246,7 @@ if (!jQuery.fn.drag) {
245
246
gridData , gridDataGetLength , gridDataGetItem ;
246
247
247
248
var columnDefaults = {
249
+ name : "" ,
248
250
resizable : true ,
249
251
sortable : false ,
250
252
minWidth : 30
@@ -510,6 +512,7 @@ if (!jQuery.fn.drag) {
510
512
. html ( "<span class='slick-column-name'>" + m . name + "</span>" )
511
513
. width ( m . width - headerColumnWidthDiff )
512
514
. attr ( "title" , m . toolTip || m . name || "" )
515
+ . data ( "fieldId" , m . id )
513
516
. appendTo ( $headers ) ;
514
517
515
518
if ( options . enableColumnReorder || m . sortable ) {
@@ -951,6 +954,7 @@ if (!jQuery.fn.drag) {
951
954
$container . unbind ( "resize" , resizeCanvas ) ;
952
955
removeCssRules ( ) ;
953
956
957
+ $canvas . unbind ( "draginit dragstart dragend drag" ) ;
954
958
$container . empty ( ) . removeClass ( uid ) ;
955
959
}
956
960
@@ -1086,6 +1090,7 @@ if (!jQuery.fn.drag) {
1086
1090
removeCssRules ( ) ;
1087
1091
createCssRules ( ) ;
1088
1092
resizeAndRender ( ) ;
1093
+ handleScroll ( ) ;
1089
1094
}
1090
1095
1091
1096
function getOptions ( ) {
@@ -1344,7 +1349,14 @@ if (!jQuery.fn.drag) {
1344
1349
function updateRowCount ( ) {
1345
1350
var newRowCount = gridDataGetLength ( ) + ( options . enableAddRow ?1 :0 ) + ( options . leaveSpaceForNewRows ?numVisibleRows - 1 :0 ) ;
1346
1351
var oldH = h ;
1347
-
1352
+ // remove the rows that are now outside of the data range
1353
+ // this helps avoid redundant calls to .removeRow() when the size of the data decreased by thousands of rows
1354
+ var l = options . enableAddRow ? gridDataGetLength ( ) : gridDataGetLength ( ) - 1 ;
1355
+ for ( var i in rowsCache ) {
1356
+ if ( i >= l ) {
1357
+ removeRowFromCache ( i ) ;
1358
+ }
1359
+ }
1348
1360
th = Math . max ( options . rowHeight * newRowCount , viewportH - scrollbarDimensions . height ) ;
1349
1361
if ( th < maxSupportedCssHeight ) {
1350
1362
// just one page
@@ -1669,7 +1681,7 @@ if (!jQuery.fn.drag) {
1669
1681
}
1670
1682
1671
1683
function handleClick ( e ) {
1672
- var $cell = $ ( e . target ) . closest ( ".slick-cell" ) ;
1684
+ var $cell = $ ( e . target ) . closest ( ".slick-cell" , $canvas ) ;
1673
1685
if ( $cell . length === 0 ) { return ; }
1674
1686
1675
1687
// are we editing this cell?
@@ -1749,7 +1761,7 @@ if (!jQuery.fn.drag) {
1749
1761
}
1750
1762
1751
1763
function handleContextMenu ( e ) {
1752
- var $cell = $ ( e . target ) . closest ( ".slick-cell" ) ;
1764
+ var $cell = $ ( e . target ) . closest ( ".slick-cell" , $canvas ) ;
1753
1765
if ( $cell . length === 0 ) { return ; }
1754
1766
1755
1767
// are we editing this cell?
@@ -1775,7 +1787,7 @@ if (!jQuery.fn.drag) {
1775
1787
}
1776
1788
1777
1789
function handleDblClick ( e ) {
1778
- var $cell = $ ( e . target ) . closest ( ".slick-cell" ) ;
1790
+ var $cell = $ ( e . target ) . closest ( ".slick-cell" , $canvas ) ;
1779
1791
if ( $cell . length === 0 ) { return ; }
1780
1792
1781
1793
// are we editing this cell?
@@ -1807,8 +1819,8 @@ if (!jQuery.fn.drag) {
1807
1819
function handleHeaderContextMenu ( e ) {
1808
1820
if ( self . onHeaderContextMenu && options . editorLock . commitCurrentEdit ( ) ) {
1809
1821
e . preventDefault ( ) ;
1810
- // TODO: figure out which column was acted on and pass it as a param to the handler
1811
- self . onHeaderContextMenu ( e ) ;
1822
+ var selectedElement = $ ( e . target ) . closest ( ".slick-header- column" , ".slick-header-columns" ) ;
1823
+ self . onHeaderContextMenu ( e , columns [ self . getColumnIndex ( selectedElement . data ( "fieldId" ) ) ] ) ;
1812
1824
}
1813
1825
}
1814
1826
@@ -1827,9 +1839,10 @@ if (!jQuery.fn.drag) {
1827
1839
function handleHover ( e ) {
1828
1840
if ( ! options . enableAutoTooltips ) return ;
1829
1841
var $cell = $ ( e . target ) . closest ( ".slick-cell" , $canvas ) ;
1830
- if ( $cell && $cell . length ) {
1842
+ if ( $cell . length ) {
1831
1843
if ( $cell . innerWidth ( ) < $cell [ 0 ] . scrollWidth ) {
1832
- $cell . attr ( "title" , $ . trim ( $cell . text ( ) ) ) ;
1844
+ var text = $ . trim ( $cell . text ( ) ) ;
1845
+ $cell . attr ( "title" , ( options . toolTipMaxLength && text . length > options . toolTipMaxLength ) ? text . substr ( 0 , options . toolTipMaxLength - 3 ) + "..." : text ) ;
1833
1846
}
1834
1847
else {
1835
1848
$cell . attr ( "title" , "" ) ;
@@ -1915,7 +1928,7 @@ if (!jQuery.fn.drag) {
1915
1928
1916
1929
currentCellNode = newCell ;
1917
1930
1918
- if ( currentCellNode !== null ) {
1931
+ if ( currentCellNode != null ) {
1919
1932
currentRow = parseInt ( $ ( currentCellNode ) . parent ( ) . attr ( "row" ) , 10 ) ;
1920
1933
currentCell = getSiblingIndex ( currentCellNode ) ;
1921
1934
@@ -2113,6 +2126,9 @@ if (!jQuery.fn.drag) {
2113
2126
return absBox ( currentCellNode ) ;
2114
2127
}
2115
2128
2129
+ function getGridPosition ( ) {
2130
+ return absBox ( $container [ 0 ] )
2131
+ }
2116
2132
function handleCurrentCellPositionChange ( ) {
2117
2133
if ( ! currentCellNode ) return ;
2118
2134
var cellBox ;
@@ -2449,7 +2465,7 @@ if (!jQuery.fn.drag) {
2449
2465
"hideSecondaryHeaderRow" : hideSecondaryHeaderRow ,
2450
2466
"setSortColumn" : setSortColumn ,
2451
2467
"getCurrentCellPosition" : getCurrentCellPosition ,
2452
-
2468
+ "getGridPosition" : getGridPosition ,
2453
2469
// IEditor implementation
2454
2470
"getEditController" : getEditController
2455
2471
} ) ;
0 commit comments