Class: HPagination
Instance Attribute Summary
Attributes inherited from HWidget
#tag
Instance Method Summary
collapse
Methods inherited from HWidget
#_addJsSlot, #_set, #_setStyle, #addJsFunction, #appendChild, #appendChilds, #buildSignature, #closeTag, #connect, #copyConstructor, #get, #getChilds, #getElementBy, #getSystemProperty, #hotLog, #openTag, #replacePlaceholder, #reset, #set, #setChilds, #setCloseTag, #setClosedTag, #setEnablePlaceholder, #setInnerHTML, #setParent, #setPlaceholder, #setPlaceholders, #setProperties, #setSlots, #setStyle, #setStyles, #setSystemProperties, #setSystemProperty, #setTag, #storeSlots, #storeStyle, #strProperties, test, #unset, widgetSpace
Constructor Details
#initialize(sourceView: nil, pages: 1, currentPage: 0, pageSize: 'all', rowsForPage: [10, 100, 'all'], **args) ⇒ HPagination
Returns a new instance of HPagination.
3
4
5
6
7
8
9
10
11
|
# File 'lib/hwidgets/hpagination.rb', line 3
def initialize(sourceView: nil, pages: 1, currentPage: 0, pageSize: 'all', rowsForPage: [10, 100, 'all'] , **args)
@sourceView = sourceView @pageSize = pageSize
@pages = pages
@currentPage = currentPage
@rowsForPage = rowsForPage
return super(class: 'hpaginationview', **args)
end
|
Instance Method Details
#comboboxSection ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# 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 ⇒ Object
60
61
62
63
|
# File 'lib/hwidgets/hpagination.rb', line 60
def html
self << self.pageDiv << self.comboboxSection << self.navigationButtons
return super
end
|
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/hwidgets/hpagination.rb', line 48
def navigationButtons
decDiv = HDivTag.new("❮", class: 'paginationview-block')
decDiv.connect(:onclick, @sourceView, "html", id: @sourceView.oid,
args: {page: [0, @currentPage - 1].max})
incDiv = HDivTag.new("❯", class: 'paginationview-block')
incDiv.connect(:onclick, @sourceView, "html", id: @sourceView.oid,
args: {page: [@sourceView.rpcPages() - 1, @currentPage + 1].min})
return [decDiv, incDiv]
end
|
#pageDiv ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# 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) ⇒ Object
13
14
15
16
17
18
|
# 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') ⇒ Object
20
21
22
|
# File 'lib/hwidgets/hpagination.rb', line 20
def setPageSize(value: 'all')
return @sourceView.html(pageSize: value)
end
|