页面显示分页前第一次的所有记录

时间:2015-06-25 22:50:26

标签: ruby-on-rails ruby pagination salesforce

问题描述:

我们有一个ROR应用程序正在调用外部系统并在页面上显示结果。但是当它第一次显示结果时,它会显示从外部系统返回的所有行,对于前2000个记录,然后它会自动刷新以显示前10个记录。

这是代码:

控制器:

  def index
    @filter_options = {
      "My Accounts" => "my",
      "My Team's Accounts" => "team"
    }

    @selected_filter = params[:selectedfilter] || "my"

    @accounts = Account.index as: current_portal_user, filter: @selected_filter
  end

模型类

  def self.index options = {}
    user = options[:as]
    role = user.role
    contact_id = user.contact_id
    account_id = user.account_id

    query_string = if options[:filter].nil?
      Account.get_all_accounts(account_id, contact_id, role)
    elsif options[:filter] == "team"
      Account.get_myteams_accounts(account_id, contact_id, role)
    elsif options[:filter] == "my"
      Account.get_my_accounts(account_id, contact_id, role)
    elsif options[:filter] == "id"
      self.index_basic_query + "WHERE Id = '#{options[:id]}'"
    end

        more_results.uniq { |acc| acc.Id }
   end

有些正文可以告诉我为什么页面会显示查询的所有记录一小段时间,然后单独刷新以显示前十条记录。

注意:我是Ruby和ROR的新手,并尽力解决这个问题。我上面发布的代码是伪代码,如果有任何语法错误或者同样的话,请耐心等待。

修改

目标: 当查询结果显示在页面上时,首先它会在执行分页之前显示结果集中的所有记录。 例如:我打开页面并选择过滤器并单击“go”按钮,对于我选择的过滤器,我期待2000条记录。所以正在发生的是页面显示所有2000条记录,然后在几分之一秒内,它刷新然后显示2000总结果集的前10条记录。

先谢谢。

0 个答案:

没有答案
相关问题