⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htmltablestore.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
			//	summary: 			//		Simple test of the hasAttribute API			//	description:			//		Simple test of the hasAttribute API			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(1, items.length);				var item = items[0];				t.assertTrue(store.hasAttribute(item,"isbn"));				t.assertTrue(!store.hasAttribute(item,"bob"));				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_containsValue(t){			//	summary: 			//		Simple test of the containsValue API			//	description:			//		Simple test of the containsValue API			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(1, items.length);				var item = items[0];				t.assertTrue(store.containsValue(item,"isbn", "A9B574"));				t.assertTrue(!store.containsValue(item,"isbn", "bob"));				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_sortDescending(t){			//	summary: 			//		Simple test of the sorting API in descending order.			//	description:			//		Simple test of the sorting API in descending order.			var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();			//Comparison is done as a string type (toString comparison), so the order won't be numeric			//So have to compare in 'alphabetic' order.			var order = [9,8,7,6,5,4,3,20,2,19,18,17,16,15,14,13,12,11,10,1];						var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(20, items.length);				for(var i = 0; i < items.length; i++){					t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());				}				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			var sortAttributes = [{attribute: "isbn", descending: true}];			store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_sortAscending(t){			//	summary: 			//		Simple test of the sorting API in ascending order.			//	description:			//		Simple test of the sorting API in ascending order.			var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();			//Comparison is done as a string type (toString comparison), so the order won't be numeric			//So have to compare in 'alphabetic' order.			var order = [1,10,11,12,13,14,15,16,17,18,19,2,20,3,4,5,6,7,8,9];									var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(20, items.length);				var itemId = 1;				for(var i = 0; i < items.length; i++){					t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());				}				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			var sortAttributes = [{attribute: "isbn"}];			store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_sortDescendingNumeric(t){			//	summary: 			//		Simple test of the sorting API in descending order using a numeric comparator.			//	description:			//		Simple test of the sorting API in descending order using a numeric comparator.			var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();			//isbn should be treated as a numeric, not as a string comparison			store.comparatorMap = {};			store.comparatorMap["isbn"] = function(a, b){				var ret = 0;				if(parseInt(a.toString()) > parseInt(b.toString())){					ret = 1;				}else if(parseInt(a.toString()) < parseInt(b.toString())){					ret = -1;				}				return ret; //int, {-1,0,1}			};			var d = new doh.Deferred();			function onComplete(items, request) {                		t.assertEqual(20, items.length);                		var itemId = 20;				for(var i = 0; i < items.length; i++){					t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());					itemId--;				}				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			var sortAttributes = [{attribute: "isbn", descending: true}];			store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_sortAscendingNumeric(t){			//	summary: 			//		Simple test of the sorting API in ascending order using a numeric comparator.			//	description:			//		Simple test of the sorting API in ascending order using a numeric comparator.			var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();			//isbn should be treated as a numeric, not as a string comparison			store.comparatorMap = {};			store.comparatorMap["isbn"] = function(a, b){				var ret = 0;				if(parseInt(a.toString()) > parseInt(b.toString())){					ret = 1;				}else if(parseInt(a.toString()) < parseInt(b.toString())){					ret = -1;				}				return ret; //int, {-1,0,1}			};			var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(20, items.length);				var itemId = 1;				for(var i = 0; i < items.length; i++){					t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());					itemId++;				}				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			var sortAttributes = [{attribute: "isbn"}];			store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_isItemLoaded(t){			//	summary: 			//		Simple test of the isItemLoaded API			//	description:			//		Simple test of the isItemLoaded API			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(1, items.length);				var item = items[0];				t.assertTrue(store.isItemLoaded(item));				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_getFeatures(t){			//	summary: 			//		Simple test of the getFeatures function of the store			//	description:			//		Simple test of the getFeatures function of the store			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var features = store.getFeatures(); 			var count = 0;			for(i in features){				t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity"));				count++;			}			t.assertEqual(2, count);		},		function testReadAPI_getAttributes(t){			//	summary: 			//		Simple test of the getAttributes API			//	description:			//		Simple test of the getAttributes API			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(1, items.length);				var item = items[0];				var attributes = store.getAttributes(item);				t.assertEqual(3,attributes.length);				for(var i=0; i<attributes.length; i++){					t.assertTrue((attributes[i] === "isbn" || attributes[i] === "title" || attributes[i] === "author"));				}				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});			return d; //Object		},		function testReadAPI_functionConformance(t){			//	summary: 			//		Simple test read API conformance.  Checks to see all declared functions are actual functions on the instances.			//	description:			//		Simple test read API conformance.  Checks to see all declared functions are actual functions on the instances.			var testStore = dojox.data.tests.stores.HtmlTableStore.getBooksStore();			var readApi = new dojo.data.api.Read();			var passed = true;			for(i in readApi){				var member = readApi[i];				//Check that all the 'Read' defined functions exist on the test store.				if(typeof member === "function"){					var testStoreMember = testStore[i];					if(!(typeof testStoreMember === "function")){						console.log("Problem with function: [" + i + "]");						passed = false;						break;					}				}			}			t.assertTrue(passed);		},/***************************************     dojo.data.api.Identity API***************************************/		function testIdentityAPI_getIdentity(t){			//	summary: 			//		Simple test of the getAttributes API			//	description:			//		Simple test of the getAttributes API			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(1, items.length);				var item = items[0];				t.assertEqual(3,store.getIdentity(item));				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});			return d; //Object		},		function testIdentityAPI_getIdentityAttributes(t){			//	summary: 			//		Simple test of the getAttributes API			//	description:			//		Simple test of the getAttributes API			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var d = new doh.Deferred();			function onComplete(items, request) {				t.assertEqual(1, items.length);				var item = items[0];				//Should have none, as it's not a public attribute.				var attributes = store.getIdentityAttributes(item);				t.assertEqual(null, attributes);				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});			return d; //Object		},		function testIdentityAPI_fetchItemByIdentity(t){			//	summary: 			//		Simple test of the fetchItemByIdentity API			//	description:			//		Simple test of the fetchItemByIdentity API			var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();			var d = new doh.Deferred();			function onItem(item, request) {				t.assertTrue(item !== null);				t.assertTrue(store.isItem(item));				t.assertEqual("A9B574", store.getValue(item, "isbn"));				d.callback(true);			}			function onError(error, request) {				d.errback(error);			}			store.fetchItemByIdentity({identity: 3, onItem: onItem, onError: onError});			return d; //Object		},		function testIdentityAPI_functionConformance(t){			//	summary: 			//		Simple test identity API conformance.  Checks to see all declared functions are actual functions on the instances.			//	description:			//		Simple test identity API conformance.  Checks to see all declared functions are actual functions on the instances.			var testStore = dojox.data.tests.stores.HtmlTableStore.getBooksStore();			var identityApi = new dojo.data.api.Identity();			var passed = true;			for(i in identityApi){				var member = identityApi[i];				//Check that all the 'Read' defined functions exist on the test store.				if(typeof member === "function"){					var testStoreMember = testStore[i];					if(!(typeof testStoreMember === "function")){						console.log("Problem with function: [" + i + "]");						passed = false;						break;					}				}			}			t.assertTrue(passed);		}	]);//Register the remote tests ... when they work.//doh.registerUrl("dojox.data.tests.stores.HtmlTableStore.remote", dojo.moduleUrl("dojox.data.tests", "ml/test_HtmlTableStore_declaratively.html"));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -