1

これはUnits表です:

<div id="table_header">Units</div>
<table class="gridView location">
  <tr class="gridViewHeader">
  <th><%= check_box("select", "all", {class: 'location'}) %></th>
  <th>Location Code</th>
  <th>Location Reference</th>
  <th>Address</th>
  </tr>

  <tr class="<%= cycle('gridViewclickableRowDialog', 'gridViewAltclickableRowDialog') %> current_location">
    <td><%= check_box("select", "all", {class: 'current_location'}) %></td>
    <td><%= current_location_id %></td>
    <td><%= current_location.Lo_Reference %></td>
    <td><%= current_location %></td>
  </tr>
</table>

これはSelected Units表です:

<div id="table_header">Selected Units</div>
<table class="gridView location">
  <tr class="gridViewHeader">
  <th><%= check_box("select", "all", {class: 'location'}) %></th>
  <th>Location Code</th>
  <th>Location Reference</th>
  <th>Address</th>
  </tr>

  <tr class="<%= cycle('gridViewclickableRowDialog', 'gridViewAltclickableRowDialog') %> current_location">
    <td><%= check_box("select", "all", {class: 'current_location'}) %></td>
    <td><%= current_location_id %></td>
    <td><%= current_location.Lo_Reference %></td>
    <td><%= current_location %></td>
  </tr>
</table>

buttonプッシュする画像

<%= image_tag("blue_right_arrow.png", id: 'blue_right_arrow', :alt => "arro", title: 'Move to Selected Units') %>

これをクリックするbuttonと、テーブルから選択した行がUnitsテーブルに転送されSelected Unitsます。

前もって感謝します!。

4

1 に答える 1

3

変更されたマークアップ

<div class="table_header">Units</div>
<table class="gridView location" id="units">
  <thead>
    <tr class="gridViewHeader">
      <th><%= check_box("select", "all", {:class => "location"}) %></th>
      <th>Location Code</th>
      <th>Location Reference</th>
      <th>Address</th>
    </tr>
  </thead>

  <tbody>
    <tr class="current_location">
      <td><%= check_box("select", "all", {:class => "current_location"}) %></td>
      <td><%= current_location_id %></td>
      <td><%= current_location.Lo_Reference %></td>
      <td><%= current_location %></td>
    </tr>
  </tbody>
</table>


<div class="table_header">Selected Units</div>
<table class="gridView" id="selected_units">
  <thead>
    <tr class="gridViewHeader">
      <th><%= check_box("select", "all") %></th>
      <th>Location Code</th>
      <th>Location Reference</th>
      <th>Address</th>
    </tr>
  </thead>

  <tbody> 
    <tr class="<%= cycle('gridViewclickableRowDialog', 'gridViewAltclickableRowDialog') %>">
      <td><%= check_box("select", "all") %></td>
      <td><%= current_location_id %></td>
      <td><%= current_location.Lo_Reference %></td>
      <td><%= current_location %></td>
    </tr>
  </tbody>
</table>

<%= image_tag("blue_right_arrow.png", id: 'blue_right_arrow', :alt => "arro", title: 'Move to Selected Units') %>

追加された新しいクラスを書き留めます。

Jqueryコード

$(document).ready(function() {
  #copying the tr
  $("#blue_right_arrow").click(function() {
    $("input.current_location").each(function(i, el) {
      if($(el).is(":checked")) {
        $("table#selected_units tbody").append($(el).parent().parent().html());
        $(el).remove()
      }
    });
  });
}); 
于 2012-10-16T10:28:37.367 に答える