Dojo DataGrid垂直向后滚动

时间:2016-11-29 08:15:44

标签: javascript dojo

我正在使用Dojo框架来创建datagrid。页面和网格加载后,选择任何行。单击并长按垂直滚动,您可以看到垂直滚动条向后滚动。此问题仅在第一次出现。我知道,这很奇怪。但我想知道导致这一特定问题的原因。 请尝试使用以下HTML代码



<!DOCTYPE HTML>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Demo: dojox/grid/DataGrid Simple Structure</title>
	<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css" media="screen">
	<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css" />
	<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojox/grid/resources/claroGrid.css" />
<style>
#grid {
	width: 560px;
	height: 300px;
}
</style>
</head>
<body class="claro">
<h1>Demo: dojox/grid/DataGrid Simple Structure</h1>

<br/>
<div id="grid"></div>

<!-- load dojo -->
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<script>
	var gridData = {
	"items": [
		{
			"bats": "R", 
			"birthDate": "1934-2-5", 
			"deathDate": null, 
			"debut": "4/13/1954 0:00:00", 
			"finalGame": "10/3/1976 0:00:00", 
			"first": "Hank", 
			"height": 72.0, 
			"id": "aaronha01", 
			"last": "Aaron", 
			"nameNote": null, 
			"nickname": "Hammer,Hammerin' Hank,Bad Henry", 
			"throws": "R", 
			"total2B": 624, 
			"total3B": 98, 
			"totalAB": 12364, 
			"totalBB": 1402, 
			"totalCS": 73, 
			"totalG": 3298, 
			"totalGAB": 3298, 
			"totalGIDP": 328, 
			"totalH": 3771, 
			"totalHBP": 32, 
			"totalHR": 755, 
			"totalIBB": 293, 
			"totalK": 1383, 
			"totalR": 2174, 
			"totalRBI": 2297, 
			"totalSB": 240, 
			"totalSF": 121, 
			"totalSH": 21, 
			"weight": 180.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1887-2-26", 
			"deathDate": "1950-11-4", 
			"debut": "4/15/1911 0:00:00", 
			"finalGame": "5/28/1930 0:00:00", 
			"first": "Pete", 
			"height": 73.0, 
			"id": "alexape01", 
			"last": "Alexander", 
			"nameNote": null, 
			"nickname": "Old Pete", 
			"throws": "R", 
			"total2B": 60, 
			"total3B": 13, 
			"totalAB": 1810, 
			"totalBB": 77, 
			"totalCS": 5, 
			"totalG": 703, 
			"totalGAB": 703, 
			"totalGIDP": null, 
			"totalH": 378, 
			"totalHBP": 2, 
			"totalHR": 11, 
			"totalIBB": null, 
			"totalK": 276, 
			"totalR": 154, 
			"totalRBI": 163, 
			"totalSB": 3, 
			"totalSF": null, 
			"totalSH": 88, 
			"weight": 185.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1852-4-17", 
			"deathDate": "1922-4-14", 
			"debut": "5/6/1871 0:00:00", 
			"finalGame": "10/3/1897 0:00:00", 
			"first": "Cap", 
			"height": 72.0, 
			"id": "ansonca01", 
			"last": "Anson", 
			"nameNote": null, 
			"nickname": "Pop", 
			"throws": "R", 
			"total2B": 581, 
			"total3B": 142, 
			"totalAB": 10277, 
			"totalBB": 983, 
			"totalCS": 16, 
			"totalG": 2523, 
			"totalGAB": 2523, 
			"totalGIDP": null, 
			"totalH": 3418, 
			"totalHBP": 32, 
			"totalHR": 97, 
			"totalIBB": null, 
			"totalK": 302, 
			"totalR": 1996, 
			"totalRBI": 2076, 
			"totalSB": 276, 
			"totalSF": null, 
			"totalSH": 27, 
			"weight": 227.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1934-4-29", 
			"deathDate": null, 
			"debut": "4/17/1956 0:00:00", 
			"finalGame": "9/28/1973 0:00:00", 
			"first": "Luis", 
			"height": 69.0, 
			"id": "aparilu01", 
			"last": "Aparicio", 
			"nameNote": null, 
			"nickname": "Little Louie", 
			"throws": "R", 
			"total2B": 394, 
			"total3B": 92, 
			"totalAB": 10230, 
			"totalBB": 736, 
			"totalCS": 136, 
			"totalG": 2601, 
			"totalGAB": 2601, 
			"totalGIDP": 184, 
			"totalH": 2677, 
			"totalHBP": 27, 
			"totalHR": 83, 
			"totalIBB": 22, 
			"totalK": 742, 
			"totalR": 1335, 
			"totalRBI": 791, 
			"totalSB": 506, 
			"totalSF": 76, 
			"totalSH": 161, 
			"weight": 160.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1907-4-2", 
			"deathDate": "1991-1-3", 
			"debut": "9/10/1930 0:00:00", 
			"finalGame": "10/1/1950 0:00:00", 
			"first": "Luke", 
			"height": 70.0, 
			"id": "applilu01", 
			"last": "Appling", 
			"nameNote": null, 
			"nickname": "Old Aches and Pains,Luscious Luke", 
			"throws": "R", 
			"total2B": 440, 
			"total3B": 102, 
			"totalAB": 8856, 
			"totalBB": 1302, 
			"totalCS": 108, 
			"totalG": 2422, 
			"totalGAB": 2422, 
			"totalGIDP": 129, 
			"totalH": 2749, 
			"totalHBP": 11, 
			"totalHR": 45, 
			"totalIBB": null, 
			"totalK": 528, 
			"totalR": 1319, 
			"totalRBI": 1116, 
			"totalSB": 179, 
			"totalSF": null, 
			"totalSH": 74, 
			"weight": 183.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1927-3-19", 
			"deathDate": "1997-9-9", 
			"debut": "4/20/1948 0:00:00", 
			"finalGame": "9/30/1962 0:00:00", 
			"first": "Richie", 
			"height": 70.0, 
			"id": "ashburi01", 
			"last": "Ashburn", 
			"nameNote": null, 
			"nickname": "Whitey,Put Put", 
			"throws": "R", 
			"total2B": 317, 
			"total3B": 109, 
			"totalAB": 8365, 
			"totalBB": 1198, 
			"totalCS": 92, 
			"totalG": 2189, 
			"totalGAB": 2189, 
			"totalGIDP": 83, 
			"totalH": 2574, 
			"totalHBP": 43, 
			"totalHR": 29, 
			"totalIBB": 25, 
			"totalK": 571, 
			"totalR": 1322, 
			"totalRBI": 586, 
			"totalSB": 234, 
			"totalSF": 18, 
			"totalSH": 112, 
			"weight": 170.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1902-5-21", 
			"deathDate": "1983-8-16", 
			"debut": "4/16/1929 0:00:00", 
			"finalGame": "4/25/1941 0:00:00", 
			"first": "Earl", 
			"height": 69.0, 
			"id": "averiea01", 
			"last": "Averill", 
			"nameNote": null, 
			"nickname": "Rock,The Earl of Snohomish", 
			"throws": "R", 
			"total2B": 401, 
			"total3B": 128, 
			"totalAB": 6353, 
			"totalBB": 774, 
			"totalCS": 57, 
			"totalG": 1668, 
			"totalGAB": 1668, 
			"totalGIDP": 7, 
			"totalH": 2019, 
			"totalHBP": 33, 
			"totalHR": 238, 
			"totalIBB": null, 
			"totalK": 518, 
			"totalR": 1224, 
			"totalRBI": 1164, 
			"totalSB": 70, 
			"totalSF": null, 
			"totalSH": 55, 
			"weight": 172.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1886-3-13", 
			"deathDate": "1963-6-28", 
			"debut": "9/21/1908 0:00:00", 
			"finalGame": "9/29/1922 0:00:00", 
			"first": "Frank", 
			"height": 71.0, 
			"id": "bakerfr01", 
			"last": "Baker", 
			"nameNote": null, 
			"nickname": "Home Run", 
			"throws": "R", 
			"total2B": 315, 
			"total3B": 103, 
			"totalAB": 5984, 
			"totalBB": 473, 
			"totalCS": 28, 
			"totalG": 1575, 
			"totalGAB": 1575, 
			"totalGIDP": null, 
			"totalH": 1838, 
			"totalHBP": 50, 
			"totalHR": 96, 
			"totalIBB": null, 
			"totalK": 182, 
			"totalR": 887, 
			"totalRBI": 987, 
			"totalSB": 235, 
			"totalSF": null, 
			"totalSH": 153, 
			"weight": 173.0
		}, 
		{
			"bats": "B", 
			"birthDate": "1891-4-20", 
			"deathDate": "1972-10-9", 
			"debut": "4/14/1915 0:00:00", 
			"finalGame": "5/31/1930 0:00:00", 
			"first": "Dave", 
			"height": 69.0, 
			"id": "bancrda01", 
			"last": "Bancroft", 
			"nameNote": null, 
			"nickname": "Beauty", 
			"throws": "R", 
			"total2B": 320, 
			"total3B": 77, 
			"totalAB": 7182, 
			"totalBB": 827, 
			"totalCS": 75, 
			"totalG": 1913, 
			"totalGAB": 1913, 
			"totalGIDP": null, 
			"totalH": 2004, 
			"totalHBP": 23, 
			"totalHR": 32, 
			"totalIBB": null, 
			"totalK": 487, 
			"totalR": 1048, 
			"totalRBI": 591, 
			"totalSB": 145, 
			"totalSF": null, 
			"totalSH": 212, 
			"weight": 160.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1931-1-31", 
			"deathDate": null, 
			"debut": "9/17/1953 0:00:00", 
			"finalGame": "9/26/1971 0:00:00", 
			"first": "Ernie", 
			"height": 73.0, 
			"id": "bankser01", 
			"last": "Banks", 
			"nameNote": null, 
			"nickname": "Mr. Cub", 
			"throws": "R", 
			"total2B": 407, 
			"total3B": 90, 
			"totalAB": 9421, 
			"totalBB": 763, 
			"totalCS": 53, 
			"totalG": 2528, 
			"totalGAB": 2528, 
			"totalGIDP": 229, 
			"totalH": 2583, 
			"totalHBP": 70, 
			"totalHR": 512, 
			"totalIBB": 198, 
			"totalK": 1236, 
			"totalR": 1305, 
			"totalRBI": 1636, 
			"totalSB": 50, 
			"totalSF": 96, 
			"totalSH": 45, 
			"weight": 180.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1867-8-4", 
			"deathDate": "1918-6-25", 
			"debut": "6/20/1888 0:00:00", 
			"finalGame": "6/15/1907 0:00:00", 
			"first": "Jake", 
			"height": 70.0, 
			"id": "becklja01", 
			"last": "Beckley", 
			"nameNote": null, 
			"nickname": "Eagle Eye", 
			"throws": "L", 
			"total2B": 473, 
			"total3B": 243, 
			"totalAB": 9526, 
			"totalBB": 616, 
			"totalCS": null, 
			"totalG": 2386, 
			"totalGAB": 2386, 
			"totalGIDP": null, 
			"totalH": 2930, 
			"totalHBP": 183, 
			"totalHR": 86, 
			"totalIBB": null, 
			"totalK": 270, 
			"totalR": 1600, 
			"totalRBI": 1575, 
			"totalSB": 315, 
			"totalSF": null, 
			"totalSH": 145, 
			"weight": 200.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1947-12-7", 
			"deathDate": null, 
			"debut": "8/28/1967 0:00:00", 
			"finalGame": "9/29/1983 0:00:00", 
			"first": "Johnny", 
			"height": 73.0, 
			"id": "benchjo01", 
			"last": "Bench", 
			"nameNote": null, 
			"nickname": "Little General", 
			"throws": "R", 
			"total2B": 381, 
			"total3B": 24, 
			"totalAB": 7658, 
			"totalBB": 891, 
			"totalCS": 43, 
			"totalG": 2158, 
			"totalGAB": 2158, 
			"totalGIDP": 201, 
			"totalH": 2048, 
			"totalHBP": 19, 
			"totalHR": 389, 
			"totalIBB": 135, 
			"totalK": 1278, 
			"totalR": 1091, 
			"totalRBI": 1376, 
			"totalSB": 68, 
			"totalSF": 90, 
			"totalSH": 11, 
			"weight": 197.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1884-5-5", 
			"deathDate": "1954-5-22", 
			"debut": "4/20/1903 0:00:00", 
			"finalGame": "7/21/1925 0:00:00", 
			"first": "Chief", 
			"height": 74.0, 
			"id": "bendech01", 
			"last": "Bender", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "R", 
			"total2B": 40, 
			"total3B": 10, 
			"totalAB": 1147, 
			"totalBB": 75, 
			"totalCS": 0, 
			"totalG": 507, 
			"totalGAB": 507, 
			"totalGIDP": 0, 
			"totalH": 243, 
			"totalHBP": 10, 
			"totalHR": 6, 
			"totalIBB": 0, 
			"totalK": 48, 
			"totalR": 102, 
			"totalRBI": 116, 
			"totalSB": 20, 
			"totalSF": 0, 
			"totalSH": 42, 
			"weight": 185.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1925-5-12", 
			"deathDate": null, 
			"debut": "9/22/1946 0:00:00", 
			"finalGame": "5/9/1965 0:00:00", 
			"first": "Yogi", 
			"height": 67.0, 
			"id": "berrayo01", 
			"last": "Berra", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "R", 
			"total2B": 321, 
			"total3B": 49, 
			"totalAB": 7555, 
			"totalBB": 704, 
			"totalCS": 26, 
			"totalG": 2120, 
			"totalGAB": 2120, 
			"totalGIDP": 146, 
			"totalH": 2150, 
			"totalHBP": 52, 
			"totalHR": 358, 
			"totalIBB": 49, 
			"totalK": 414, 
			"totalR": 1175, 
			"totalRBI": 1430, 
			"totalSB": 30, 
			"totalSF": 44, 
			"totalSH": 9, 
			"weight": 185.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1958-6-15", 
			"deathDate": null, 
			"debut": "4/10/1982 0:00:00", 
			"finalGame": "8/27/1999 0:00:00", 
			"first": "Wade", 
			"height": 74.0, 
			"id": "boggswa01", 
			"last": "Boggs", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "R", 
			"total2B": 578, 
			"total3B": 61, 
			"totalAB": 9180, 
			"totalBB": 1412, 
			"totalCS": 35, 
			"totalG": 2440, 
			"totalGAB": 2439, 
			"totalGIDP": 236, 
			"totalH": 3010, 
			"totalHBP": 23, 
			"totalHR": 118, 
			"totalIBB": 180, 
			"totalK": 745, 
			"totalR": 1513, 
			"totalRBI": 1014, 
			"totalSB": 24, 
			"totalSF": 96, 
			"totalSH": 29, 
			"weight": 190.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1900-4-23", 
			"deathDate": "1959-12-11", 
			"debut": "8/18/1922 0:00:00", 
			"finalGame": "9/16/1937 0:00:00", 
			"first": "Jim", 
			"height": 72.0, 
			"id": "bottoji01", 
			"last": "Bottomley", 
			"nameNote": null, 
			"nickname": "Sunny Jim", 
			"throws": "L", 
			"total2B": 465, 
			"total3B": 151, 
			"totalAB": 7471, 
			"totalBB": 664, 
			"totalCS": 15, 
			"totalG": 1991, 
			"totalGAB": 1991, 
			"totalGIDP": 33, 
			"totalH": 2313, 
			"totalHBP": 43, 
			"totalHR": 219, 
			"totalIBB": null, 
			"totalK": 591, 
			"totalR": 1177, 
			"totalRBI": 1422, 
			"totalSB": 58, 
			"totalSF": null, 
			"totalSH": 177, 
			"weight": 180.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1917-7-17", 
			"deathDate": "2001-8-10", 
			"debut": "9/9/1938 0:00:00", 
			"finalGame": "8/24/1952 0:00:00", 
			"first": "Lou", 
			"height": 71.0, 
			"id": "boudrlo01", 
			"last": "Boudreau", 
			"nameNote": null, 
			"nickname": "Old Shufflefoot,Handsome Lou", 
			"throws": "R", 
			"total2B": 385, 
			"total3B": 66, 
			"totalAB": 6029, 
			"totalBB": 796, 
			"totalCS": 50, 
			"totalG": 1646, 
			"totalGAB": 1646, 
			"totalGIDP": 155, 
			"totalH": 1779, 
			"totalHBP": 34, 
			"totalHR": 68, 
			"totalIBB": null, 
			"totalK": 309, 
			"totalR": 861, 
			"totalRBI": 789, 
			"totalSB": 51, 
			"totalSF": null, 
			"totalSH": 164, 
			"weight": 185.0
		}, 
		{
			"bats": "R", 
			"birthDate": "1879-6-11", 
			"deathDate": "1944-12-4", 
			"debut": "8/27/1897 0:00:00", 
			"finalGame": "10/3/1915 0:00:00", 
			"first": "Roger", 
			"height": 69.0, 
			"id": "bresnro01", 
			"last": "Bresnahan", 
			"nameNote": null, 
			"nickname": "The Duke Of Tralee", 
			"throws": "R", 
			"total2B": 218, 
			"total3B": 71, 
			"totalAB": 4481, 
			"totalBB": 714, 
			"totalCS": 3, 
			"totalG": 1446, 
			"totalGAB": 1446, 
			"totalGIDP": null, 
			"totalH": 1252, 
			"totalHBP": 67, 
			"totalHR": 26, 
			"totalIBB": null, 
			"totalK": 99, 
			"totalR": 682, 
			"totalRBI": 530, 
			"totalSB": 212, 
			"totalSF": null, 
			"totalSH": 112, 
			"weight": 200.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1953-5-15", 
			"deathDate": null, 
			"debut": "8/2/1973 0:00:00", 
			"finalGame": "10/3/1993 0:00:00", 
			"first": "George", 
			"height": 72.0, 
			"id": "brettge01", 
			"last": "Brett", 
			"nameNote": null, 
			"nickname": "Mullet", 
			"throws": "R", 
			"total2B": 665, 
			"total3B": 137, 
			"totalAB": 10349, 
			"totalBB": 1096, 
			"totalCS": 97, 
			"totalG": 2707, 
			"totalGAB": 2707, 
			"totalGIDP": 235, 
			"totalH": 3154, 
			"totalHBP": 33, 
			"totalHR": 317, 
			"totalIBB": 229, 
			"totalK": 908, 
			"totalR": 1583, 
			"totalRBI": 1595, 
			"totalSB": 201, 
			"totalSF": 120, 
			"totalSH": 26, 
			"weight": 185.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1939-6-18", 
			"deathDate": null, 
			"debut": "9/10/1961 0:00:00", 
			"finalGame": "9/30/1979 0:00:00", 
			"first": "Lou", 
			"height": 71.0, 
			"id": "brocklo01", 
			"last": "Brock", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "L", 
			"total2B": 486, 
			"total3B": 141, 
			"totalAB": 10332, 
			"totalBB": 761, 
			"totalCS": 307, 
			"totalG": 2616, 
			"totalGAB": 2616, 
			"totalGIDP": 114, 
			"totalH": 3023, 
			"totalHBP": 49, 
			"totalHR": 149, 
			"totalIBB": 124, 
			"totalK": 1730, 
			"totalR": 1610, 
			"totalRBI": 900, 
			"totalSB": 938, 
			"totalSF": 46, 
			"totalSH": 47, 
			"weight": 170.0
		}, 
		{
			"bats": "L", 
			"birthDate": "1858-5-8", 
			"deathDate": "1932-8-2", 
			"debut": "6/23/1879 0:00:00", 
			"finalGame": "10/4/1904 0:00:00", 
			"first": "Dan", 
			"height": 74.0, 
			"id": "broutda01", 
			"last": "Brouthers", 
			"nameNote": null, 
			"nickname": "Big Dan", 
			"throws": "L", 
			"total2B": 460, 
			"total3B": 205, 
			"totalAB": 6711, 
			"totalBB": 840, 
			"totalCS": null, 
			"totalG": 1673, 
			"totalGAB": 1673, 
			"totalGIDP": null, 
			"totalH": 2296, 
			"totalHBP": 105, 
			"totalHR": 106, 
			"totalIBB": null, 
			"totalK": 238, 
			"totalR": 1523, 
			"totalRBI": 1296, 
			"totalSB": 256, 
			"totalSF": null, 
			"totalSH": 2, 
			"weight": 207.0
		}, 
		 
		{
			"bats": "R", 
			"birthDate": "1955-9-16", 
			"deathDate": null, 
			"debut": "4/5/1974 0:00:00", 
			"finalGame": "10/3/1993 0:00:00", 
			"first": "Robin", 
			"height": 72.0, 
			"id": "yountro01", 
			"last": "Yount", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "R", 
			"total2B": 583, 
			"total3B": 126, 
			"totalAB": 11008, 
			"totalBB": 966, 
			"totalCS": 105, 
			"totalG": 2856, 
			"totalGAB": 2856, 
			"totalGIDP": 217, 
			"totalH": 3142, 
			"totalHBP": 48, 
			"totalHR": 251, 
			"totalIBB": 95, 
			"totalK": 1350, 
			"totalR": 1632, 
			"totalRBI": 1406, 
			"totalSB": 271, 
			"totalSF": 123, 
			"totalSH": 104, 
			"weight": 165.0
		},
		{
			"bats": "L", 
			"birthDate": "1858-5-8", 
			"deathDate": "1932-8-2", 
			"debut": "6/23/1879 0:00:00", 
			"finalGame": "10/4/1904 0:00:00", 
			"first": "Dan", 
			"height": 74.0, 
			"id": "broutda01", 
			"last": "Brouthers", 
			"nameNote": null, 
			"nickname": "Big Dan", 
			"throws": "L", 
			"total2B": 460, 
			"total3B": 205, 
			"totalAB": 6711, 
			"totalBB": 840, 
			"totalCS": null, 
			"totalG": 1673, 
			"totalGAB": 1673, 
			"totalGIDP": null, 
			"totalH": 2296, 
			"totalHBP": 105, 
			"totalHR": 106, 
			"totalIBB": null, 
			"totalK": 238, 
			"totalR": 1523, 
			"totalRBI": 1296, 
			"totalSB": 256, 
			"totalSF": null, 
			"totalSH": 2, 
			"weight": 207.0
		}, 
		 
		{
			"bats": "R", 
			"birthDate": "1955-9-16", 
			"deathDate": null, 
			"debut": "4/5/1974 0:00:00", 
			"finalGame": "10/3/1993 0:00:00", 
			"first": "Robin", 
			"height": 72.0, 
			"id": "yountro01", 
			"last": "Yount", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "R", 
			"total2B": 583, 
			"total3B": 126, 
			"totalAB": 11008, 
			"totalBB": 966, 
			"totalCS": 105, 
			"totalG": 2856, 
			"totalGAB": 2856, 
			"totalGIDP": 217, 
			"totalH": 3142, 
			"totalHBP": 48, 
			"totalHR": 251, 
			"totalIBB": 95, 
			"totalK": 1350, 
			"totalR": 1632, 
			"totalRBI": 1406, 
			"totalSB": 271, 
			"totalSF": 123, 
			"totalSH": 104, 
			"weight": 165.0
		},
		{
			"bats": "L", 
			"birthDate": "1858-5-8", 
			"deathDate": "1932-8-2", 
			"debut": "6/23/1879 0:00:00", 
			"finalGame": "10/4/1904 0:00:00", 
			"first": "Dan", 
			"height": 74.0, 
			"id": "broutda01", 
			"last": "Brouthers", 
			"nameNote": null, 
			"nickname": "Big Dan", 
			"throws": "L", 
			"total2B": 460, 
			"total3B": 205, 
			"totalAB": 6711, 
			"totalBB": 840, 
			"totalCS": null, 
			"totalG": 1673, 
			"totalGAB": 1673, 
			"totalGIDP": null, 
			"totalH": 2296, 
			"totalHBP": 105, 
			"totalHR": 106, 
			"totalIBB": null, 
			"totalK": 238, 
			"totalR": 1523, 
			"totalRBI": 1296, 
			"totalSB": 256, 
			"totalSF": null, 
			"totalSH": 2, 
			"weight": 207.0
		}, 
		 
		{
			"bats": "R", 
			"birthDate": "1955-9-16", 
			"deathDate": null, 
			"debut": "4/5/1974 0:00:00", 
			"finalGame": "10/3/1993 0:00:00", 
			"first": "Robin", 
			"height": 72.0, 
			"id": "yountro01", 
			"last": "Yount", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "R", 
			"total2B": 583, 
			"total3B": 126, 
			"totalAB": 11008, 
			"totalBB": 966, 
			"totalCS": 105, 
			"totalG": 2856, 
			"totalGAB": 2856, 
			"totalGIDP": 217, 
			"totalH": 3142, 
			"totalHBP": 48, 
			"totalHR": 251, 
			"totalIBB": 95, 
			"totalK": 1350, 
			"totalR": 1632, 
			"totalRBI": 1406, 
			"totalSB": 271, 
			"totalSF": 123, 
			"totalSH": 104, 
			"weight": 165.0
		},
		{
			"bats": "L", 
			"birthDate": "1858-5-8", 
			"deathDate": "1932-8-2", 
			"debut": "6/23/1879 0:00:00", 
			"finalGame": "10/4/1904 0:00:00", 
			"first": "Dan", 
			"height": 74.0, 
			"id": "broutda01", 
			"last": "Brouthers", 
			"nameNote": null, 
			"nickname": "Big Dan", 
			"throws": "L", 
			"total2B": 460, 
			"total3B": 205, 
			"totalAB": 6711, 
			"totalBB": 840, 
			"totalCS": null, 
			"totalG": 1673, 
			"totalGAB": 1673, 
			"totalGIDP": null, 
			"totalH": 2296, 
			"totalHBP": 105, 
			"totalHR": 106, 
			"totalIBB": null, 
			"totalK": 238, 
			"totalR": 1523, 
			"totalRBI": 1296, 
			"totalSB": 256, 
			"totalSF": null, 
			"totalSH": 2, 
			"weight": 207.0
		}, 
		 
		{
			"bats": "R", 
			"birthDate": "1955-9-16", 
			"deathDate": null, 
			"debut": "4/5/1974 0:00:00", 
			"finalGame": "10/3/1993 0:00:00", 
			"first": "Robin", 
			"height": 72.0, 
			"id": "yountro01", 
			"last": "Yount", 
			"nameNote": null, 
			"nickname": null, 
			"throws": "R", 
			"total2B": 583, 
			"total3B": 126, 
			"totalAB": 11008, 
			"totalBB": 966, 
			"totalCS": 105, 
			"totalG": 2856, 
			"totalGAB": 2856, 
			"totalGIDP": 217, 
			"totalH": 3142, 
			"totalHBP": 48, 
			"totalHR": 251, 
			"totalIBB": 95, 
			"totalK": 1350, 
			"totalR": 1632, 
			"totalRBI": 1406, 
			"totalSB": 271, 
			"totalSF": 123, 
			"totalSH": 104, 
			"weight": 165.0
		},
		
	]
};

	var grid, dataStore, store;
	require([
		"dojox/grid/DataGrid",
		"dojo/store/Memory",
		"dojo/data/ObjectStore",
		"dojo/request",
		"dojo/domReady!"
	], function(DataGrid, Memory, ObjectStore,request){
			store = new Memory({ data: gridData.items });
			dataStore = new ObjectStore({ objectStore: store });

			grid = new DataGrid({
				store: dataStore,
				query: { id: "*" },
				structure: [
					{ name: "First Name", field: "first", width: "84px" },
					{ name: "Last Name", field: "last", width: "84px" },
					{ name: "Bats", field: "bats", width: "70px" },
					{ name: "Throws", field: "throws", width: "70px" },
					{ name: "G", field: "totalG", width: "60px" },
					{ name: "AB", field: "totalAB", width: "60px" },
					{ name: "Games as Batter", field: "totalGAB", width: "120px" },
					{ name: "R", field: "totalR", width: "60px" },
					{ name: "RBI", field: "totalRBI", width: "60px" },
					{ name: "BB", field: "totalBB", width: "60px" },
					{ name: "K", field: "totalK", width: "60px" },
					{ name: "H", field: "totalH", width: "60px" },
					{ name: "2B", field: "total2B", width: "60px" },
					{ name: "3B", field: "total3B", width: "60px" },
					{ name: "HR", field: "totalHR", width: "60px" }
				]
			});

			grid.placeAt("grid");
			// since we created this grid programmatically, call startup to render it
			//grid.startup();
			
			grid.startup();
			//grid.selection.setSelected(0, false);
			//grid.selection.clear();
			//grid.setScrollTop(10);
			 /*grid.on('MouseUp',function(event) {
				//console.log("mouseup ==>"+grid.scrollTop);
				//console.log(document.getElementById("grid").scrollHeight);
				grid.setScrollTop(document.getElementById("grid").scrollHeight);
            });
			
			grid.on('MouseDown',function(event){
              //console.log("mousedown ==>"+grid.scrollTop);
            });

			*/
		});
	

	function getSelectedRows() {
		var items = grid.selection.getSelected();
		alert(items.length);
	}
</script>
<input type="button" value="GetSelectedRows" onclick="getSelectedRows()">
</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

这是因为dojox/grid/DataGridinfinite scroll,因此,它会在您滚动时对数据进行分页,如果您检查dojox/grid/DataGrid的来源,您会发现它从dojox/grid/_Grid延伸{1}}它包含dojox/grid/_Scroller_Scroller注册到onscroll函数中domNode的{​​{1}}事件:

init

if(this.scrollboxNode){ this.scrollboxNode.scrollTop = 0; this.scroll(0); this.scrollboxNode.onscroll = lang.hitch(this, 'onscroll'); } 函数用于计算要显示的页面

onscroll

这是功能的代码,其余功能在onscroll: function(){ this.scroll(this.scrollboxNode.scrollTop); }, scroll: function(inTop){ this.grid.scrollTop = inTop; if(this.colCount){ this.startPacify(); this.findPage(inTop); var h = this.height; var b = this.getScrollBottom(inTop); for(var p=this.page, y=this.pageTop; (p<this.pageCount)&&((b<0)||(y<b)); p++){ y += this.needPage(p, y); } this.firstVisibleRow = this.getFirstVisibleRow(this.page, this.pageTop, inTop); this.lastVisibleRow = this.getLastVisibleRow(p - 1, y, b); // indicates some page size has been updated if(h != this.height){ this.repositionPages(p-1); } this.endPacify(); } }, dojox/grid/DataGrid

希望这有助于清除你的想法