class HPagination

Public Class Methods

new(sourceView: nil, pages: 1, currentPage: 0, pageSize: 'all', rowsForPage: [10, 100, 'all'] , **args) click to toggle source
Calls superclass method HDivTag::new
# File lib/hwidgets/hpagination.rb, line 3
def initialize(sourceView: nil, pages: 1, currentPage: 0, pageSize: 'all', rowsForPage: [10, 100, 'all'] , **args)
  @sourceView = sourceView # l'oggetto da paginare
  @pageSize = pageSize
  @pages = pages
  @currentPage = currentPage
  @rowsForPage = rowsForPage

  return super(class: 'hpaginationview', **args)
end

Public Instance Methods

comboboxSection() click to toggle source
# File lib/hwidgets/hpagination.rb, line 37
def comboboxSection
    
  div = HDivTag.new(class: 'paginationview-block') 
  div << HWidget.new("span", "Rows:")
  div << selectDiv = HSelectTag.new("", "", 
                 items: @rowsForPage, values: @rowsForPage, class: "hcombobox")
  selectDiv.connect(:onchange, self, "setPageSize", id: @sourceView.oid, attributes: ":obj.value")
  return div
  
end
html() click to toggle source
Calls superclass method HWidget#html
# File lib/hwidgets/hpagination.rb, line 60
def html
  self << self.pageDiv << self.comboboxSection << self.navigationButtons
  return super
end
navigationButtons() click to toggle source
pageDiv() click to toggle source
# File lib/hwidgets/hpagination.rb, line 25
def pageDiv
  div = HDivTag.new(class: 'page-box', onclick: 'hpaginationView.editMode(this)') 
  div << HWidget.new("span", "Page:")
  div << currentPageDiv = HWidget.new("input", class: 'current-page', type: 'text', value: @currentPage + 1,  
                     onkeypress: "hpaginationView.keyPress(this, event)")
  currentPageDiv.connect(:onblur, self, "setCurrentPage", id: @sourceView.oid, attributes: ":obj.value")

  div << HWidget.new("span", "of")
  div << HWidget.new("span", @pages, class: 'total-pages')
  return div
end
setCurrentPage(value: 1) click to toggle source
# File lib/hwidgets/hpagination.rb, line 13
def setCurrentPage(value: 1)
  value = eval(value) - 1
  value = 0 if value < 0
  value = @pages - 1 if value >= @pages
  return @sourceView.html(page: value)
end
setPageSize(value: 'all') click to toggle source
# File lib/hwidgets/hpagination.rb, line 20
def setPageSize(value: 'all')
  return @sourceView.html(pageSize: value)
end