WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 sortable table loses data in IE, Andrus Moor, July 2, 2003
     Re:sortable table loses data in IE, Erik Arvidsson, July 4, 2003
         Re:sortable table loses data in IE, Andrus Moor, July 5, 2003
             Re:sortable table loses data in IE, Adam Killander, July 15, 2003

Subject: Re:sortable table loses data in IE From: Adam Killander Date: July 15, 2003

I am using IE6 (Windows 2000) and I have no problem with data loss for select elements or <input type="text">.

But you might want to change the onbeforesort() and onsort() methods a little to allow both checkboxes and other input elements in the same row:

 

if (/MSIE/.test(navigator.userAgent)) {
 
 // backup check box and radio button checked state
 SortableTable.prototype.onbeforesort = function () {
  var table = this.element;
  var inputs = table.getElementsByTagName("INPUT");
  var l = inputs.length;
  for (var i = 0; i < l; i++) {
   if ( /^(checkbox|radio)$/.test(inputs[i].type) ) {
    inputs[i].parentNode.parentNode.setAttribute('_checked_' + SortableTable.getCellIndex(inputs[i].parentNode), inputs[i].checked);
   }
  }
 };
 
 // restore check box and radio button checked state
 SortableTable.prototype.onsort = function () {
  var table = this.element;
  var inputs = table.getElementsByTagName("INPUT");
  var l = inputs.length;
  for (var i = 0; i < l; i++) {
   if ( /^(checkbox|radio)$/.test(inputs[i].type) ) {
    inputs[i].checked = inputs[i].parentNode.parentNode.getAttribute('_checked_' + SortableTable.getCellIndex(inputs[i].parentNode));
   }
  }
 };
}


/Adam Killander

 

From: Andrus Moor
Sent: July 5, 2003
Subject: Re:sortable table loses data in IE

I have also <input type=text> and <select> (combo boxes) fields in table.

Is it possible to alter the script so that data loss does not occur for those 3 types of input elements ?

Are there any samples which shows how to not lose data where using <select> and <input type=text> elements in table ?

This is a known IE bug. See the Demos page for the Sortable Table for workaround.

erik

________________________________________________________

To reproduce:
1. Run the code in the end of this message in IE
2. Click in the checkbox to select it
3. Click in the checkbox column header to sort

Observed result:
Check mark is lost.
Expected result:
Check mark must remain .

Additional notes:
This bug does not occur in Mozilla.

Any idea how to fix this ?

Code to reproduce:
<script type="text/javascript" src="js/sortabletable.js"></script>
<link type="text/css" rel="StyleSheet" href="css/sortabletable.css" />
<table class="sort-table" id="table-1" cellspacing="0">
<thead>
<tr>
<td>Check</td>
<td>item</td>
</tr>
</thead>
<tbody>
<tr>
<td><input type=checkbox></td>
<td>pine</td>
</tr>
<tr>
<td><input type=checkbox></td>
<td>orange</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var st1 = new SortableTable(document.getElementById("table-1"));
</script></body></html>






Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX