Hi,

  I have attached an image file with this port. Here, Currently I am
sorting (order) users depending on email id. I would like to sort the
users depending on checkbox status so that selected (checked) users will
be listed first and then other emails will be listed in the order of
email.

<% User.all( :order => :email, :conditions => ( @current_user.excelfore?
? [] : ["role != 'excelfore'"] ) ).each_with_index do |u,i| %>
    <tr<%= ' class="even_row"' if i.even? %>>
      <td class="checkbox">
        <input id="checkbox_<%= i %>" type="checkbox" <%=
'checked="checked"' if @group.users.include?( u ) %> onchange="if (
this.checked ) {
            <%= remote_function( :url => { :action => :add_user, :id =>
@group.id, :user => u.id },
                                 :before => "checkbox_onchange_before(
#{ i } )",
                                 :success => "checkbox_onchange_success(
#{ i }, 'user added' )",
                                 :failure => "checkbox_onchange_failure(
#{ i }, 'add user' )",
                                 :complete =>
"checkbox_onchange_complete( #{ i } )" ) %>;
          } else {
            <%= remote_function( :url => { :action => :remove_user, :id
=> @group.id, :user => u.id },
                                 :before => "checkbox_onchange_before(
#{ i } )",
                                 :success => "checkbox_onchange_success(
#{ i }, 'user removed' )",
                                 :failure => "checkbox_onchange_failure(
#{ i }, 'remove user' )",
                                 :complete =>
"checkbox_onchange_complete( #{ i } )" ) %>;
          }" />
      </td>
      <td><span class="checkbox_label" onclick="checkbox_click( <%= i %>
)"><%= u.email %></span></td>
      <td>
        <% if u.name.present? %>
          <span class="checkbox_info" onclick="checkbox_click( <%= i %>
)"><%= u.name %></span>
        <% end %>
      </td>
      <td id="status_<%= i %>" class="checkbox_status"></td>
    </tr>
  <% end %>

Attachments:
http://www.ruby-forum.com/attachment/7369/sortingofusers.jpg


-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to