1. 在处理list-detail的时候,有必要定义多个model和store吗?更新详细信息的时候,应该用store还是ajax自己处理?2. ajax可以发送x-www-form-urlencoded格式的内容吗?3. json序列化会返回一个奇怪的时间格式,grid可以用renderer解决,form就比较麻烦了,除了更改序列化的方式外,有没有更好的方法?每次都进行转换又比较烦4. 官方竟然没提供DateTimeField?好囧5. 官方有没有提供从xml读取tree数据的方法?
解决方案 »
- 请大侠看看这个自定义控件源码,哪里出错了(gridview合并)
- VS2003转VS2005的项目中使用UpdatePanel整个页面仍然刷新,何解?
- 关于操作表格的问题。如何改变选中行的颜色。而其余行的颜色不变。
- 怎么写一个样式来完全控制gridView和TreeView的样式呢?
- 关于ArrayList类越界的问题,搞不明白,请大家指教.
- ASP.NET(C#) 操作dbf
- asp.net的几个简单问题(VB.NET开发),请指教
- 帮帮初学者,DataGrid的问题
- 我想在Application_BeginRequest读Session,为什么总报错?
- 那本 .net C#的书好呢??我这就去买!!
- 请大家帮我解决下瓶颈问题,跪谢大家了!!
- 读取数据库 比较符号进行比较
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","demo_post2.asp",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("fname=Henry&lname=Ford");
}
</script>
</head>
<body><h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">Request data</button>
<div id="myDiv"></div>
</body>
</html>
http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_post2
补充一个extjs的例子(所有的js的ajax都使用的xmlhttprequest)
Ext.Ajax.request({
url: 'com/functions.cfc',
success: successMethod,
failure: errorMethod,
headers: {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"},
params: {method:'setupLife',argument1:arg1,argument2:arg2}
});
2.可以
3.什么样的格式啊?
4.
5.可以。我写过一个 。 可以参考一下 Ext.app.MyXMLLoader = Ext.extend(Ext.ux.XmlTreeLoader, {
processAttributes: function (attr) {
attr.id = attr.id;
attr.href = attr.url;
attr.text = attr.name;
attr.url = attr.url;
attr.leaf = attr.leaf;
}
});
// left Tree
var menu = new Ext.tree.TreePanel({
title: '系统菜单',
region: "west",
animate: true,
autoScroll: true,
enableTabScroll: true,
collapsible: true,
collapsed: true,
split: true,
rootVisible: true,
lines: true,
width: 220,
minSize: 220,
maxSize: 220,
root: new Ext.tree.AsyncTreeNode({
text: '主菜单',
draggable: false, // 根节点不容许拖动
expanded: false
}),
loader: new Ext.app.MyXMLLoader({
preloadChildren: true,
clearOnLoad: false,
dataUrl: "/manage/LoadTreeXML" //这里访问到action 里 。然后action解析xml。也可以直接写xml url
}),
collapseFirst: false
});
menu.expandAll();
menu.on('click', function (node) {
if (node.leaf == 'true' && typeof node.leaf != 'undefined') {
var tab = tabMain.getComponent(node.id);
if (!tab) {
tab = tabMain.add({
'id': node.id,
'title': node.text,
closable: true, //通过html载入目标页
html: '<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + node.attributes.upost + '"></iframe>'
});
}
tabMain.setActiveTab(tab);
}
});
/// <summary>
/// tree xml数据源
/// </summary>
///
[SessionFilter]
public void LoadTreeXML()
{
StreamReader sr = new StreamReader(Server.MapPath("\\Content\\xml\\xml-tree-data.xml"));
Response.ContentType = "text/xml; charset=utf-8";
string _temp = sr.ReadToEnd();
sr.Close();
Response.Write(_temp);
Response.End();
}
引用到页面就行。 官方有下载!/*
* Ext JS Library 2.2.1
* Copyright(c) 2006-2009, Ext JS, LLC.
* [email protected]
*
* http://extjs.com/license
*//**
* @class Ext.ux.XmlTreeLoader
* @extends Ext.tree.TreeLoader
* <p>A TreeLoader that can convert an XML document into a hierarchy of {@link Ext.tree.TreeNode}s.
* Any text value included as a text node in the XML will be added to the parent node as an attribute
* called <tt>innerText</tt>. Also, the tag name of each XML node will be added to the tree node as
* an attribute called <tt>tagName</tt>.</p>
* <p>By default, this class expects that your source XML will provide the necessary attributes on each
* node as expected by the {@link Ext.tree.TreePanel} to display and load properly. However, you can
* provide your own custom processing of node attributes by overriding the {@link #processNode} method
* and modifying the attributes as needed before they are used to create the associated TreeNode.</p>
* @constructor
* Creates a new XmlTreeloader.
* @param {Object} config A config object containing config properties.
*/
Ext.ux.XmlTreeLoader = Ext.extend(Ext.tree.TreeLoader, {
/**
* @property XML_NODE_ELEMENT
* XML element node (value 1, read-only)
* @type Number
*/
XML_NODE_ELEMENT: 1,
/**
* @property XML_NODE_TEXT
* XML text node (value 3, read-only)
* @type Number
*/
XML_NODE_TEXT: 3, // private override
processResponse: function (response, node, callback) {
var xmlData = response.responseXML;
var root = xmlData.documentElement || xmlData; try {
node.beginUpdate();
node.appendChild(this.parseXml(root));
node.endUpdate(); if (typeof callback == "function") {
callback(this, node);
}
} catch (e) {
this.handleFailure(response);
}
}, // private
parseXml: function (node) {
var nodes = [];
Ext.each(node.childNodes, function (n) {
if (n.nodeType == this.XML_NODE_ELEMENT) {
var treeNode = this.createNode(n);
if (n.childNodes.length > 0) {
var child = this.parseXml(n);
if (typeof child == 'string') {
treeNode.attributes.innerText = child;
} else {
treeNode.appendChild(child);
}
}
nodes.push(treeNode);
}
else if (n.nodeType == this.XML_NODE_TEXT) {
var text = n.nodeValue.trim();
if (text.length > 0) {
return nodes = text;
}
}
}, this); return nodes;
}, // private override
createNode: function (node) {
var attr = {
tagName: node.tagName
}; Ext.each(node.attributes, function (a) {
attr[a.nodeName] = a.nodeValue;
}); this.processAttributes(attr); return Ext.ux.XmlTreeLoader.superclass.createNode.call(this, attr);
}, /*
* Template method intended to be overridden by subclasses that need to provide
* custom attribute processing prior to the creation of each TreeNode. This method
* will be passed a config object containing existing TreeNode attribute name/value
* pairs which can be modified as needed directly (no need to return the object).
*/
processAttributes: Ext.emptyFn
});
问题是这样的,比如我要显示文章列表,只需要显示文章标题,服务端提供的列表数据也只有id和标题,这时候有没有必要定义一个简化版的列表model? 但是这样一来,就没办法通过store来同步数据了
列表的数据{id, title}, 编辑详细信息的数据{id, title, content},这样不能通过同一个store来读取更新吧
获取列表的时候。为什么不把content一起取出 。不显示即可
可以啊
Ext.Ajax.request({
url: "myProxy.ashx",
method: "GET",
async: false, //ASYNC 是否异步( TRUE 异步 , FALSE 同步)
params: { //将真正的页面(服务)url参数传递到代理页面
u: url,
m: "GET",
t: ""
},
4. 官方竟然没提供DateTimeField?好囧
5. 官方有没有提供从xml读取tree数据的方法?
-----------------------------------
json很好用是要转换的, 应该不麻烦吧。
同理,需要写代码
5.参考代码如下
http://blog.csdn.net/jason_dct/article/details/8454280