Loading ...
Sorry, an error occurred while loading the content.

Datatable draggable columns problem

Expand Messages
  • Kel
    I am having a problem using draggable columns in the datatable. When the datatable is placed inside another drag drop object, the column reordering gets
    Message 1 of 2 , Jul 1 7:02 PM
    • 0 Attachment
      I am having a problem using draggable columns in the datatable. When the datatable is placed inside another drag drop object, the column reordering gets messed up. columnReorderEvent gets fired twice. The first time, the columns are correct, but the second they are out of order. This is happening in both IE7 and Firefox 3. Thanks for any help with this.

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title>Test</title>
      <!-- Combo-handled YUI CSS files: -->
      <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.7.0/build/fonts/fonts-min.css&2.7.0/build/datatable/assets/skins/sam/datatable.css">
      <!-- Combo-handled YUI JS files: -->
      <script type="text/javascript" src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo-dom-event/yahoo-dom-event.js&2.7.0/build/dragdrop/dragdrop-min.js&2.7.0/build/element/element-min.js&2.7.0/build/datasource/datasource-min.js&2.7.0/build/datatable/datatable-min.js"></script>
      </head>
      <body class="yui-skin-sam">
      <div id="panel1"><div id="datatable1"></div></div>

      <script type="text/javascript">
      YAHOO.util.Event.onContentReady("panel1", function () {
      var dd = new YAHOO.util.DD(this);

      var data = {
      bookorders: [
      {id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"},
      {id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"},
      {id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"},
      {id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}
      ]
      }

      var myColumnDefs = [
      {key:"id", sortable:true, resizeable:true},
      {key:"date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true},
      {key:"quantity", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true},
      {key:"amount", formatter:YAHOO.widget.DataTable.formatCurrency, sortable:true, resizeable:true},
      {key:"title", sortable:true, resizeable:true}
      ];

      var myDataSource = new YAHOO.util.DataSource(data.bookorders);
      myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
      myDataSource.responseSchema = {fields: ["id","date","quantity","amount","title"]};

      var myDataTable = new YAHOO.widget.DataTable("datatable1", myColumnDefs, myDataSource, {draggableColumns: true});

      myDataTable.subscribe("columnReorderEvent", function(o){
      var col_set = this.getColumnSet();
      var defs = col_set.getDefinitions();
      var headers = "";

      for(var i=0; i<defs.length; i++) headers += defs[i].key + ",";
      alert(headers);
      });
      });
      </script>
      </body>
      </html>
    • Kel
      Anyone?
      Message 2 of 2 , Jul 7 7:22 PM
      • 0 Attachment
        Anyone?
      Your message has been successfully submitted and would be delivered to recipients shortly.