Categories | Question details Back To List | ||
dhtmlxgrid Hi, I've the following code... The problem is that when i integrate my code with struts it doesn't work. I get errors like invalid xml etc. when actually the xmk is proper. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page language="java" import="java.util.*,java.text.*,com.crisil.ram.master.*,com.crisil.ram.common.*,com.crisil.ram.util.*" %> <% SimpleDateFormat sDF = new SimpleDateFormat("dd MMM yyyy hh:mm a",Locale.US); String strDate = sDF.format(new Date(System.currentTimeMillis() - (long)82800000)); response.setHeader("Expires",strDate); %> <html> <head> <title>CAM 3.2 - Client Master </title> <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css"> <link rel="STYLESHEET" type="text/css" href="../../codebase/ext/dhtmlxgrid_pgn_bricks.css"> <link rel="STYLESHEET" type="text/css" href="../../codebase/skins/dhtmlxmenu_standard.css"> <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxcombo.css"> <script>_css_prefix="../../codebase/"; _js_prefix="../../codebase/"; </script> <script src="../../codebase/dhtmlxcommon.js"></script> <script src="../../codebase/dhtmlxgrid.js"></script> <script src="../../codebase/dhtmlxgridcell.js"></script> <script src="../../codebase/dhtmlxcombo.js" type="text/javascript"></script> <script src="../../codebase/dhtmlxmenu.js" language="JavaScript" ></script> <script src="../../codebase/ext/dhtmlxgrid_srnd.js"></script> <script src="../../codebase/ext/dhtmlxgrid_filter.js"></script> <script src="../../codebase/ext/dhtmlxgrid_pgn.js"></script> <script src="../../codebase/ext/dhtmlxgrid_splt.js"></script> <script src="../../codebase/ext/dhtmlxgrid_group.js"></script> <script src="../../codebase/ext/dhtmlxgrid_mcol.js"></script> <script src="../../codebase/excells/dhtmlxgrid_excell_calck.js"></script> <script src="../../codebase/excells/dhtmlxgrid_excell_acheck.js"></script> <script src="../../codebase/excells/dhtmlxgrid_excell_calendar.js"></script> <script src="../../codebase/excells/dhtmlxgrid_excell_clist.js"></script> <script src="../../codebase/excells/dhtmlxgrid_excell_combo.js"></script> <script src="../../codebase/dhtmlxdataprocessor.js"></script> </head> <body onresize="return true;" oncontextmenu="return false;" > <link rel='STYLESHEET' type='text/css' href='../common/style.css'> <table> <tr> <td> <div id="gridbox" width="98%" height="720px" style=""></div> <div id="pagingArea" width="98%"></div> <input type = text name = "names" value = "1"> </td> </tr> <tr> <td> <div id="messanger"> </div> <a href="javascript:void(0)" onclick="mygrid.addRow((new Date()).valueOf(),[0,'','','',false,'na',false,''],mygrid.getRowIndex(mygrid.getSelectedId()))">Add row</a><br> <a href="javascript:void(0)" onclick="mygrid.deleteSelectedItem()">Remove Selected Row</a> <br><br> <input type="Checkbox" onclick="doOnAutoupdateChecked(this.checked)"> Enable Auto Update <div id="updatemodes" style="display:none;"> <input type="radio" name="updm" id="updmdflt" value="cell" style="margin-left:20px;" onclick="myDataProcessor.setUpdateMode(this.value)" checked>Cell based<br> <input type="radio" name="updm" value="row" style="margin-left:20px;" onclick="myDataProcessor.setUpdateMode(this.value)">Row based </div> <input type="Button" onclick="myDataProcessor.sendData()" id="updatebutton" value="Update" style="display:inline;"> <input type="Button" onclick="myDataProcessor.sendData()" id="deletebutton" value="Delete" style="display:inline;"> </td> </tr> </table> <script> /* -- Context Menu --------------------------- */ function onButtonClick(menuitemId){ var data=mygrid.contextID.split("_"); //rowInd_colInd var rId = data[0]; var cInd = data[1]; switch(menuitemId){ case "add": mygrid.addRow((new Date()).valueOf(),["","","","","","","",""], mygrid.getRowIndex(data[0])); break; case "delete": window.setTimeout("mygrid.deleteRow("+rId+");",200) break; } } function onShowMenu(rowId,celInd,grid){ var arr = ["inc","dec"]; for(var i = 0 ; i < arr.length; i++){ menu.hideItem(arr[i]); } return true } menu = new dhtmlXMenuObject(null,"standard"); menu.setImagePath("../../codebase/imgs/"); //menu.setIconsPath("../images/"); menu.renderAsContextMenu(); menu.setOpenMode("web"); menu.attachEvent("onClick",onButtonClick); menu.loadXML("contextmenu.xml"); /* ------------------------------------------- */ /* -- Grid ------------------------------------*/ mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("../../codebase/imgs/"); mygrid.enableContextMenu(menu); mygrid.enablePaging(true,35,20,"pagingArea",true); mygrid.setPagingSkin("bricks"); mygrid.attachEvent("onBeforeContextMenu", onShowMenu); mygrid.imgURL = "../../codebase/imgs/"; mygrid.setSkin("light"); mygrid.init(); //window.status = 'Loading grid...' //mygrid.loadXML("clientcolumns.xml"); mygrid.loadXML("/cam32stdstruts/DataModificationScreen/samples/ToDomain/XMLCols/Client_Master.xml",function() { mygrid.loadXML("/cam32stdstruts/DMS.do?action=ClientXml&offset=0&dt=" ); }); //mygrid.splitAt(2); /* ------------------------------------------- */ //mygrid.enableSmartRendering(true); /* -- Grid Column Validations -----------------*/ mygrid.attachEvent("onEditCell", function(stage,rowId,cInd){ if(stage == 1 && cInd >= 0 ) { if(mygrid.editor && mygrid.editor.obj ) { mygrid.editor.obj.onkeypress = function(e) { var pattern = /^[a-zA-Z0-9-() /-]+$/; chr=String.fromCharCode(event.keyCode); if (!chr.match(pattern)) event.returnValue = false; if(this.value.length>=10){ return false; } } } } } /* ------------------------------------------- */ myDataProcessor = new dataProcessor("/cam32stdstruts/DMS.do?action=xmlSaveData"); //myDataProcessor.enableDebug(true); myDataProcessor.enableDataNames(true); //myDataProcessor.setVerificator(1) //myDataProcessor.setVerificator(3,checkIfNotZero) myDataProcessor.setUpdateMode("off");//available values: cell (default), row, off //myDataProcessor.defineAction("error",myErrorHandler); myDataProcessor.setTransactionMode("POST",true); myDataProcessor.init(mygrid); </script> </body> </html> Answer posted by dhxSupport on Mar 13, 2009 06:06 Incorrect XML error means that printed data has XML syntax errors, in case of dyn. generation of data, most possible reason - some script error occurs during data generation and error info corrupt XML - data was printed in different encoding than XML ( iso-8859-1 vs UTF ) which cause xml syntax error To check exact reason, you can load the same url ( getGridRecords.asp with parameters ) in separate window or use debug version of dhtmlxcommon.js http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&q=2545&ssr=yes&s=dhtmlxcommon |