Gridview
-
Hi, I am new to php,I want to show a table in grid.need help.
-
Hi, I am new to php,I want to show a table in grid.need help.
-
Hi, I am new to php,I want to show a table in grid.need help.
I was playing with something the otherday that might be whhat you'r after. It just displays a (dynamically generated, in this simple example) table, and allows editing by just double-clicking a cell. <pre><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function makeEdit(tgtObj) { tgtObj.ondblclick=""; tgtObj.innerHTML = '<input class="myInput" type="text" value="' + tgtObj.innerHTML + '" />'; } function makeSelect(tgtObj) { var oldStr, newStr; oldStr = tgtObj.innerHTML; newStr = '<select class="myInput" name="select"><option value=0>0</option><option value=1>1</option></select>'; tgtObj.ondblclick=""; tgtObj.innerHTML = newStr; } // called by the ondblclick function of a table <td> </td> cell function editModeOn() { var curCol, btnIdStr=""; var tgtRowObj = this.parentNode; var numCells = tgtRowObj.cells.length; var rand_no = Math.ceil(100*Math.random()); btnIdStr = "btn_"; btnIdStr += rand_no; for (curCol=0; curCol<numCells-1; curCol++) { makeEdit(tgtRowObj.cells[curCol]); } tgtRowObj.cells[curCol].ondblclick = null; tgtRowObj.cells[numCells-1].innerHTML = "<input type='button' id='"+btnIdStr+"' value='save'/>"; // tgtRowObj.cells[numCells-1].onclick=null; document.getElementById(btnIdStr).onclick=editModeOff; } function editModeOff() { var str = "editModeOff: " + this.id; var parentCell = this.parentNode; var parentRow = parentCell.parentNode; var tgtObj = parentRow; var i, n, numCells, thisCell; numCells = tgt
-
I was playing with something the otherday that might be whhat you'r after. It just displays a (dynamically generated, in this simple example) table, and allows editing by just double-clicking a cell. <pre><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function makeEdit(tgtObj) { tgtObj.ondblclick=""; tgtObj.innerHTML = '<input class="myInput" type="text" value="' + tgtObj.innerHTML + '" />'; } function makeSelect(tgtObj) { var oldStr, newStr; oldStr = tgtObj.innerHTML; newStr = '<select class="myInput" name="select"><option value=0>0</option><option value=1>1</option></select>'; tgtObj.ondblclick=""; tgtObj.innerHTML = newStr; } // called by the ondblclick function of a table <td> </td> cell function editModeOn() { var curCol, btnIdStr=""; var tgtRowObj = this.parentNode; var numCells = tgtRowObj.cells.length; var rand_no = Math.ceil(100*Math.random()); btnIdStr = "btn_"; btnIdStr += rand_no; for (curCol=0; curCol<numCells-1; curCol++) { makeEdit(tgtRowObj.cells[curCol]); } tgtRowObj.cells[curCol].ondblclick = null; tgtRowObj.cells[numCells-1].innerHTML = "<input type='button' id='"+btnIdStr+"' value='save'/>"; // tgtRowObj.cells[numCells-1].onclick=null; document.getElementById(btnIdStr).onclick=editModeOff; } function editModeOff() { var str = "editModeOff: " + this.id; var parentCell = this.parentNode; var parentRow = parentCell.parentNode; var tgtObj = parentRow; var i, n, numCells, thisCell; numCells = tgt
I'm not a fan of just writing HTML with javascript e.g.
str += '</tr>';
I would rather use thedocument.createElement( [tag name] );
function. I'm also a huge fan of jQuery. Below is how I would go about creating a table in Javascript.Create Table function createTable(rows, columns, newId, parent) { $(parent) .append( $(document.createElement('table')) .attr('id' , newId) ); for (var rowNumber = 1; rowNumber <= rows; rowNumber++) { $('#' + newId) .append( $(document.createElement('tr')) .attr('class', (rowNumber % 2 == 0) ? 'even' : 'odd') ); for (var columnNumber = 1; columnNumber <= columns; columnNumber++) { $('#' + newId + ' tr:last-child') .append( $(document.createElement('td')) .html('(' + columnNumber + ', ' + rowNumber + ')') ); } } } <div id="parent"></div>
Boredom is a wonderful thing.
If at first you don't succeed, you're not Chuck Norris.