Categories | Question details Back To List | ||
dhtmlxgrid Hi, I've the following code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <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> </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> </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"); //window.status = 'Loading data...' alert('Loading data...'); mygrid.loadXML("L client.xml"); mygrid.init(); //mygrid.splitAt(2); /* ------------------------------------------- */ //mygrid.enableSmartRendering(true); /* -- Grid Column Validations -----------------*/ mygrid.attachEvent("onEditCell", function(stage,rowId,cInd){ if(stage == 1 && cInd == 4 ) { 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; } } } } if(stage == 1 && cInd == 0) { if(mygrid.editor && mygrid.editor.obj ) { mygrid.editor.obj.onkeypress = function(e) { if(event.keyCode<48 || event.keyCode>57) event.keyCode=""; if(this.value.length>=8) { return false; } if(isNaN(this.value)) { return false; } } } } if(stage == 1 && cInd == 2) { if(mygrid.editor && mygrid.editor.obj ) { mygrid.editor.obj.onkeypress = function(e) { if(this.value.length>=3) { return false; } } } } if(cInd > 2 && stage == 1 && cInd != 4 ) { 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; } if(this.value.length>=5){ return false; } if(this.value > 10000){ this.value = 0; alert("Values cannot be greater than 10000"); return false; } if(isNaN(this.value)) { this.value = 0; alert("Please enter numbers only"); } } mygrid.editor.obj.onkeyup = function(e) { if(this.value > 10000){ this.value = 0; alert("Values cannot be greater than 100"); //return false; } if(this.value > 10000 && this.value.indexOf(".") == -1) { this.value = 0.00; alert("Please enter decimal values less than 10000"); } if(isNaN(this.value)) { this.value = 0; alert("Please enter numbers only"); } } } } return true; }) /* ------------------------------------------- */ </script> </body> </html> in the above if I remove alert('Loading data...'); the page loads normally other wise i get an error saying this.obj.firstChild is Answer posted on Feb 25, 2009 05:10 As far as I can understood you are loading configuration and data by separate xml request, right? In such case your code need to be organized as mygrid.loadXML("clientcolumns.xml",function(){ mygrid.loadXML("L client.xml"); }); // mygrid.init(); - not necessary at all Answer posted by dilip on Feb 26, 2009 01:33 Thanks, That worked. |