Categories | Question details Back To List | ||
Destructor / Clear All error - Grid Refresh I have a grid set up with events attached to the onEditCell, onBeforeRowDeleted and onBeforeSelect events (Here's the javascript syntax) mygrid.attachEvent("onEditCell",doOnCellEdit); mygrid.attachEvent("onBeforeRowDeleted",doBeforeRowDeleted); mygrid.attachEvent("onBeforeSelect",doBeforeSelect); <script> var newRow = false; function doOnCellEdit(stage,rowId,cellInd) { if(newRow==false) { if(stage==2) { newVal = mygrid.cells(mygrid.getSelectedId(),mygrid.getSelectedCellIndex()).getValue(); alert('Update Database AJAX - select ID:' + rowId + ', ' + '/Cell ID: ' + cellInd + '/Value: ' + newVal); return true; } } } function doBeforeRowDeleted(rowId) { retType = confirm("Are you sure you want to delete row"); if (retType==true) { delVal = mygrid.cells(rowId,0).getValue(); alert('Call AJAX to delete ID: ' + rowId + ', ' + ' First Cell: ' + delVal); } return retType; } function doAddRow() { if(newRow) { alert('Please complete the entry on the current row'); } else { var newId = (new Date()).valueOf() mygrid.addRow(newId,"",mygrid.getRowsNum()) mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true); mygrid.editCell(mygrid.getRowIndex(newId)) newRow = true; } } function doBeforeSelect(oldRowID, newRowID) { if(oldRowID!=newRowID) { if(newRow) { retType = confirm('Test Validation Here'); if (retType==true) { alert('add new row through AJAX'); newRow = false; return retType; } else { alert('raise validation error'); return retType; } } } return true; } </script> I would like the page this is on to call any XML and plug the XML into the grid without forcing a reload of the whole page. I've tried 3 methods to reload the grid with a new XML (the XML also includes the header information so the init of the grid is simply First, I tried a clearAll(true) and loadXML(). When that failed, I tried destroying the grid (mygrid.destructor();), I got the following error: line: 23 Char: 433 Error: Object doesn't support this property or method Code: 0 URL: grid.htm Line 23 is the first line of my doOnCellEdit function and it doesn't have 433 characters, So I thought it might be something in the codebase. So I tried detaching the events (mygrid.detachEvent("onEditCell",doOnCellEdit); ...) line: 550 Char: 192 Error: 'this[...]' is null or is not an object Code: 0 URL: grid.htm There's not even 550 lines in grid.htm so I figured it was something inside of the core that was not allowing the destruction of the grid with events tied to it (due to the error when actually executing the detach event function). Am I doing something wrong here???? Answer posted by Support on Nov 10, 2008 02:12 if you need to reload only data grid.clearAll(); //without parameter grid.load(new_data); http://dhtmlx.com/docs/products/dhtmlxGrid/samples/initialization_loading/grid_refresh.html?un=1226313290000 http://dhtmlx.com/docs/products/dhtmlxGrid/samples/initialization_loading/grid_reload.html?un=1226313278000 >>I tried destroying the grid (mygrid.destructor();), I got the following error: After destructor usage, grid's object is not accessible anymore, you need to created new instance >>So I tried detaching the events (mygrid.detachEvent("onEditCell",doOnCellEdit); ...) detachEvent works as var event_id = mygrid.attachEvent("onEditCell",doOnCellEdit); ... mygrid.detachEvent(event_id); ( but it is not necessary for data reloading ) |