`

Change the title of component from store

 
阅读更多

今天在问答中看到这样的问题,我这里给出简单的实现,没有后台,纯extjs代码实现component的titlechange问题

 

Ext.define('TitleChange', {
	extend: 'Ext.data.Model',
	fields: [
		 {name: 'title',mapping:'title'}
	],
	idProperty: 'titleChange'
});

Ext.onReady(function () {
	var myData = [
		{'title':"WindowTitileChange"}
	];
	var store = Ext.create('Ext.data.ArrayStore', {
		model: 'TitleChange',
		data: myData,
		autoLoad: true
    });
	var win = Ext.create('Ext.window.Window', {
		title: 'Hello',
		height: 200,
		width: 400
	});

	store.load({
		 callback : function(r, options, success) {  
			win.setTitle(store.getAt(0).data.title);
			win.show();
		}
	});

});
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Test</title>
	<link rel="stylesheet" type="text/css" href="../../extjs-4.1.0/resources/css/ext-all.css" charset="UTF-8">
	<script type="text/javascript" src="../../extjs-4.1.0/ext-all-debug.js"></script>
	<script type="text/javascript" src="test.js"></script>
</head>
<body>
	<div id="test" style="margin:10px;height:800px;"></div>
</body>
</html>
 
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics