Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Gridview

Gridview

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpcsshelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jaraldumary
    wrote on last edited by
    #1

    Hi, I am new to php,I want to show a table in grid.need help.

    F enhzflepE 2 Replies Last reply
    0
    • J jaraldumary

      Hi, I am new to php,I want to show a table in grid.need help.

      F Offline
      F Offline
      fly904
      wrote on last edited by
      #2

      It's not PHP, but look into HTML tables[^].

      If at first you don't succeed, you're not Chuck Norris.

      1 Reply Last reply
      0
      • J jaraldumary

        Hi, I am new to php,I want to show a table in grid.need help.

        enhzflepE Offline
        enhzflepE Offline
        enhzflep
        wrote on last edited by
        #3

        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

        F 1 Reply Last reply
        0
        • enhzflepE enhzflep

          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

          F Offline
          F Offline
          fly904
          wrote on last edited by
          #4

          I'm not a fan of just writing HTML with javascript e.g. str += '</tr>'; I would rather use the document.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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups