javafx框架tornadofx入门实战18_pagination

2019-12-26 18:19:07 浏览数 (4)

代码语言:javascript复制
import tornadofx.*

class MainView18 : View("pagination") {
    val persions = (1..10).map {
        "name${it}"
    }.asObservable()
    val tbl=tableview(persions){
        column("name",String::class){
            value { it.value }
        }
    }
    val rowPerPage=3
    val pg=pagination(persions.size/rowPerPage 1,0){
        setPageFactory {
            borderpane{
                center=tbl.apply {
                   val fromIndex=currentPageIndex*rowPerPage
                    val toIndex=Math.min(fromIndex rowPerPage,persions.size)
                    items=persions.subList(fromIndex,toIndex).asObservable()
                }
                prefHeight=200.0

            }

        }
    }

1 人点赞