Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong number of rows on per_page method #67

Open
arielwulkan opened this issue Mar 1, 2019 · 5 comments
Open

Wrong number of rows on per_page method #67

arielwulkan opened this issue Mar 1, 2019 · 5 comments

Comments

@arielwulkan
Copy link

arielwulkan commented Mar 1, 2019

I'm getting a mismatch between the per_page and number of row actually rendered although the results count is correct.

the code:

Controller:

def providers
    @employee_certifications_grid = initialize_grid(EmployeeCertification.includes(employee: [:orders]).where(status: "active",employees: {status: "active"},orders: {taker_id: current_company.id}), order_direction: 'asc', per_page: 15)
  end

View:

<section class="section">
  <div class="columns is-centered">
    <div class="column">
      <%= grid(@employee_certifications_grid) do |g|

        g.column name: 'Colaborador', attribute: 'nome', assoc: :employee, filter: false

        g.column name: 'Documento', attribute: 'name', assoc: :certification, filter: false

        g.column name: 'Descição', attribute: 'title', assoc: :certification, filter: false

        g.column name: 'Arquivo', filter: false do |employee_certification|
          link_to employee_certification.document.filename, employee_certification.document, target: :_blank 
        end

        g.column name: 'Validade', attribute: 'expiration_date', filter: false do |employee_certification|
          if employee_certification.expiration_date
            if employee_certification.expiration_date < employee_certification.employee.orders.active.minimum(:due)
              [employee_certification.expiration_date.strftime("%d/%m/%Y"), {style: 'background-color: rgb(255, 105, 104);'}]
            else
              employee_certification.expiration_date.strftime("%d/%m/%Y")
            end
          else
            "--"
          end
        end

        g.column name: 'Pedidos', filter: false do |employee_certification|
          link_to 'visualizar pedidos', root_path
        end

        
      end -%>

      <p>
        IDs of records on the current page:
        <%= @employee_certifications_grid.current_page_records.map(&:id).to_sentence %>
      </p>
      <p>
        IDs of all records:
        <%= @employee_certifications_grid.all_pages_records.map(&:id).to_sentence %>
      </p>
    </div>
  </div>
</section>

Image of the result:
2019-03-01 1

@JasonBarnabe
Copy link
Collaborator

Same as #60?

@arielwulkan
Copy link
Author

arielwulkan commented Mar 1, 2019

Looks similar. I'm in Rails 5.2.0, though. So it should be corrected.

#60 (comment)

@arielwulkan arielwulkan changed the title Wrong number of rows on per_page meth Wrong number of rows on per_page method Mar 1, 2019
@arielwulkan
Copy link
Author

The problem persists even when not using the per_page method
As in:

def providers
    @employee_certifications_grid = initialize_grid(EmployeeCertification, include:[:certification,{employee: :orders}] , conditions: {status: "active", employees: {status: "active"}, orders: {taker_id: current_company.id}} )
  end

2019-03-01 3

@Vinnie1991
Copy link

Is there an update for this?

@afdev82
Copy link

afdev82 commented Mar 11, 2020

Maybe this commit could fix this problem: kreintjes@e3006b3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants