This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup_custom_json_for_datagrid(shops) | |
json_data = shops.to_json(only: [:id, :name], include: { concept: { only: :name, include: { chain: { only: :name} } } }) | |
jsonResponse = "{\"current\": #{params[:current]}, \"rowCount\": #{params[:rowCount]}, \"rows\": #{json_data}, \"total\": #{shops.length}}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@shops = Shop.includes(concept: [:chain]).where(where_clause_map).order("#{attribute} #{ordering}").limit(params[:rowCount]).offset(offset) | |
Where: | |
Shop includes concept and in turn concept includes chain | |
and | |
where_clause_map looks like: {"id" => "[1,2]", "shop_concepts" => "1" ,"shop_chains.id"=> "1"} |