Method: Wice::GridViewHelper#get_row_content
- Defined in:
- lib/wice/helpers/wice_grid_view_helpers.rb
#get_row_content(rendering, ar, sorting_dependant_row_cycling) ⇒ Object
:nodoc:
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/wice/helpers/wice_grid_view_helpers.rb', line 168 def get_row_content(rendering, ar, sorting_dependant_row_cycling) #:nodoc: cell_value_of_the_ordered_column = nil row_content = '' rendering.each_column(:in_html) do |column| cell_block = column.cell_rendering_block opts = column.html opts = opts ? opts.clone : {} column_block_output = if column.class == Columns.get_view_column_processor(:action) cell_block.call(ar, params) else call_block(cell_block, ar) end if column_block_output.is_a?(Array) unless column_block_output.size == 2 raise WiceGridArgumentError.new('When WiceGrid column block returns an array it is expected to contain 2 elements only - ' \ 'the first is the contents of the table cell and the second is a hash containing HTML attributes for the <td> tag.') end column_block_output, additional_opts = column_block_output unless additional_opts.is_a?(Hash) raise WiceGridArgumentError.new('When WiceGrid column block returns an array its second element is expected to be a ' \ "hash containing HTML attributes for the <td> tag. The returned value is #{additional_opts.inspect}. Read documentation.") end additional_css_class = nil if additional_opts.key?(:class) additional_css_class = additional_opts[:class] additional_opts.delete(:class) elsif additional_opts.key?('class') additional_css_class = additional_opts['class'] additional_opts.delete('class') end opts.merge!(additional_opts) Wice::WgHash.add_or_append_class_value!(opts, additional_css_class) unless additional_css_class.blank? end if sorting_dependant_row_cycling && column.attribute && grid.ordered_by?(column) cell_value_of_the_ordered_column = column_block_output end row_content += content_tag(:td, column_block_output, opts) end [row_content, cell_value_of_the_ordered_column] end |