http://alibubu.iteye.com/blog/63201 为你的图像和层增加拖放功能
http://wdzwdz.itpub.net/post/197/463500 xml array
http://my.donews.com/devil/2007/04/
http://littlecoder.blog.163.com/blog/static/76195840200832882330192/ grid
<span onclick="alert(mygrid.selectAll());">全选</span>
<span onclick="alert(mygrid.getSelectedRowId());">获取选中的id</span>
<span onclick="alert(mygrid.getCheckedRows(0));">checkbox选中的id</span>
mygrid.loadXML("../../../get") //get是servlet的url-pattern(servlet返回的是xml)
黄色的亮色可以改变 this.rowsCol[i].className+=" rowselected";// 查找css样式
mygrid.attachEvent("onKeyPress",onKeyPressed);
...
function onKeyPressed(code,ctrl,shift){
if(code==67&&ctrl){
mygrid.setCSVDelimiter("\t")
mygrid.copyBlockToClipboard()
}
if(code==86&&ctrl){
mygrid.pasteBlockFromClipboard()
}
return true;
}
mygrid.addRow(’x3′,’0, ,0, ,0, ,0,0′,mygrid.getRowsNum())
mygrid.setColumnColor(”#d5f1ff,,,,,,,#99CCFF”); //设置列背景颜色
mygrid.setColumnMinWidth(50,0);
//mygrid.setSkin(”xp”); //XP风格
mygrid.enableAlterCss(”even”,”uneven”); //颜色交替
//mygrid.enableLightMouseNavigation(true); //鼠标导航
//mygrid.enableKeyboardSupport(true); //热键
mygrid.setOnEditCellHandler(doOnCellEdit); //编辑事件
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("dhtmlxGrid12/imgs/");
mygrid.setHeader("检验项名称, 单项收费,检验依据,判定依据,备注");
mygrid.setInitWidths("200,150,200,200,200") //mygrid.setInitWidths("*,150,150");
mygrid.setColAlign("left,right,left,left,left")
mygrid.setColTypes("ed,price,ed,ed,txt");
mygrid.setColSorting("str,str,str,str,str")
mygrid.selMultiRows = true;
mygrid.enableAutoHeigth(true);
mygrid.enableLightMouseNavigation(true);
mygrid.enableKeyboardSupport(true);
mygrid.init();
//mygrid.loadXML("../grid.xml");
function pasteContent2Mycontent(){
// alert("pasteContent2Mycontent");
//var wdzContent = document.getElementbyId("wdzContent");
//alert("data=" + data);
var data = parseContentToArray();
var i=0;
var rowData;
var itemA ,itemB ,itemB ,itemD ,itemE;
for(i=0;i<=data.length-1;i++){
//rowData = data[i].join(",") ;
itemA = data[i][0];
itemB = data[i][1];
itemC = data[i][2];
itemD = data[i][3];
itemE = data[i][4];
alert('itemB='+itemB)
alert('data['+i+"]="+data[i]);
//mygrid.addRow(itemA,itemB,itemC,itemD,itemE);
mygrid.addRow(1,data[i]);
}
//alert("data length=" + s);
//alert("data length=" +s.length);
wdzContent.innerHTML = data;
}
function parseContentToArray(){
var data = getClipboard();
//alert("data=" + data);
var arrayData = data.split("n");
//alert("data length=" + arrayData.length);
var i=1;
var listData =new Array();
for(i=0 ; i<arrayData.length-1 ; i++) {
listData[i] = arrayData[i].split(" ");
//alert("listData[" +i+"]=" + listData[i]);
}
var aaa= listData[1];
//alert("listData[1][1]="+aaa[1]);
return listData;
}
</script>
2.servlet部分代码:
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("Content-type: text/xml");
//encoding may be different in your case
String str="<?xml version=\"1.0\" encoding=\"utf-8\"?>";
str+="<rows id=\"10\">";
str+="<row id=\"11\">"; //这个代表了显示在页面的那行数据的id
str+="<cell><![CDATA[1]]></cell>";
str+="<cell><![CDATA[1]]></cell>";
str+="<cell><![CDATA[1]]></cell>";
str+="<cell><![CDATA[1]]></cell>";
str+="<cell><![CDATA[\"1\"]]></cell>";
str+="<cell><![CDATA[\"1\"]]></cell>";
str+="<cell><![CDATA[\"1\"]]></cell>";
//str+="<cell><![CDATA[".gmdate("m/d/Y",strtotime($row['pub_date']))."]]></cell>");
str+="<cell><![CDATA[2/3/10]]></cell>";
str+="</row>";
}