创建自定义排序DataGrid控件的例子(读取xml)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white" viewSourceURL="srcview/index.html">
<mx:Script>
<!--[CDATA[
import mx.collections.SortField;
import mx.collections.Sort;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.utils.ObjectUtil;
private function sortOld():void {
var sortField:SortField = new SortField();
sortField.compareFunction = test2_compareFunc;
sortField.descending = checkBox.selected;
var oldSort:Sort = new Sort();
oldSort.fields = [sortField];
xmlListColl.sort = oldSort;
xmlListColl.refresh();
}
private function sortNew():void {
var sortField:SortField = new SortField();
sortField.compareFunction = test3_compareFunc;
sortField.descending = checkBox.selected;
var sort:Sort = new Sort();
sort.fields = [sortField];
xmlListColl.sort = sort;
xmlListColl.refresh();
}
private function resetSort():void {
xmlListColl.sort = null;
xmlListColl.refresh();
}
private function dataGridCol_labelFunc(item:XML, col:DataGridColumn):String
{
//(@name == col.dataField)的代码的作用是筛选
return item.*.(@name == col.dataField).text();
}
private function test2_compareFunc(itemA:XML, itemB:XML):int {
var valueA:String = itemA.test2.text();
var valueB:String = itemB.test2.text();
return ObjectUtil.stringCompare(valueA, valueB);
}
private function test3_compareFunc(itemA:XML, itemB:XML):int {
var valueA:String = itemA.test3.text();
var valueB:String = itemB.test3.text();
return ObjectUtil.stringCompare(valueA, valueB);
}
]]-->
</mx:Script>
<mx:XML id="tests" source="tests.xml" />
<mx:XMLListCollection id="xmlList
相关文档:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE hibernate-configuration (View Source for full doctype...)>
- <!-- Generated by MyEclipse Hibernate Tools.
--> - <!-- 以上几行所有的hibernate.cfg.xml都相同
--> [url=file:///C:/Documents%20and%20Settings/ ......
一.生成document对象。
import org.jdom.*;
import org.jdom.input.SAXBuilder;
public class ReportDocUtil {
public ReportDocUtil() {
}
/**
* <p>Description:covert xml file to Document</p>
* @param url 格式xml文件的存放的相对路径
& ......
此XML实例以服务器端部门管理为例:(其界面如下)
private void btn_UpdateGroup_Click(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
& ......
package cn.com.xml.vo;
public class RosterVo {
private String id; //学号
private String name; //学生姓名
private String age; //年龄
private String skill; //科目 ......