npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-pagination-ht

v1.2.3

Published

a pagination component base react

Downloads

32

Readme

react-pagination 分页组件

使用(usage):

npm install react-pagination-ht --save;

import ReactPagination  from "react-pagination-ht";

简介(summary): 在做后台开发的时候,分页组件绝对是很重要的一环。刚好我就遇到这么一个情况,需要对日志做个系统的管理。

现在在后台管理中常用的分页组件是easygrid.js,在vue和react大行其道的前端圈,easygrid.js...怎么说呢有点过时了。

用这个也不符合我做这个系统的初衷,于是在npm找了些用react做的分页组件,npm下来,import...

报错异常的多,而且还不符合我的业务场景。easygrid.js倒是很符合,但是你懂的,既然用react做,那就用react做,

分页组件: 自由度要高,可以控制每一列的渲染。

render方法是

分页组件配置(configuration):

	<ReactPagination
	tHead={[
					"日志ID",
					"标题",
					"发布时间",
					"操作"
				]} 
			searchUrl="/requestUrl"
                            param={{id:this.state.id,tittle:this.state.tittle,time:this.state.time}}
			lists={[
					{type:"text",
					rowDataProp:"id"},
					{type:"text",
					rowDataProp:"tittle"},
					{type:"render",
					render:this.transformTime.bind(this)},
					{type:"render",
					render:this.generator.bind(this)}
				]}
				pagesListNum={7}
			mainCallBack={this.mainCallBack.bind(this)}/>

Props说明(usage of props):

1.tHead:table head 标题行 

2.searchUrl:action request address

3.param为请求参数。

4.lists 定制每一行的列渲染行为,这点和easygrid很相似,如果规定为render,则方法的第一个参数为rowData,你可以为所欲为。

5.最后一个为主回调方法,第一个参数为请求的全量数据,第二个参数为分页的页数。

注意(pay attention): 传递给服务端的两个字段为:pagesListNum,intStart。全部请求的参数为

id:"1",//from props
tittle:"xxx", //from props
time:"123113", //from props
pagesListNum:7 //from this component
intStart:17 //from this component

最后附加在包装组件中以上两个渲染方法的实现(wrap component implements methods):

generator(rowData){
	return (<div style={{display:"inline-block"}}><span onClick={this.edit.bind(this,rowData.id)} className="operation-span" style={{display:"inline-block",
							backgroundColor:"",
							borderRadius:"3px",
							padding:"10px",
							paddingTop:"3px",
							paddingBottom:"3px",
							backgroundColor:"#50cf8e",
							color:"white",
							cursor:"pointer"
							}}>编辑</span>
							<span className="operation-span-delete" 
							style={{display:"inline-block",
							borderRadius:"3px",
							padding:"10px",
							paddingTop:"3px",
							paddingBottom:"3px",
							backgroundColor:"#f69581",
							marginLeft:"20px",
							color:"white",
							cursor:"pointer"
							}}
							onTouchTap={this.deleteArticleSetId.bind(this,rowData.id)}>删除</span></div>)
}

// transform  timestamp to normal time
transformTime(rowData){
	return new Date(parseInt(rowData.time)).toLocaleString().replace(/:\d{1,2}$/,' ');
}

请求的数据格式(result of the requestUrl):

{
"count": 285,
"resultList": [
    {
        "_id": "59358ac0daea9d0a6c1d3400",
        "id": 28,
        "tittle": "萨克的撒大黄是是是空的阿达啊哈大大",
        "value": "google",
        "time": 1496681150653,
        "updateTime": "1497792799187"
    },
    {
        "_id": "59358ac0daea9d0a6c1d342c",
        "id": 72,
        "tittle": "黄涛",
        "value": "Google ",
        "time": 1496681150713
    },
    {
        "_id": "59358ac3daea9d0a6c1d343d",
        "id": 89,
        "tittle": "黄涛",
        "value": "Google ",
        "time": 1496681150729
    },
    {
        "_id": "59358ac3daea9d0a6c1d344a",
        "id": 102,
        "tittle": "黄涛",
        "value": "Google 。",
        "time": 1496681150743
    },
    {
        "_id": "59358ac3daea9d0a6c1d344c",
        "id": 104,
        "tittle": "黄涛",
        "value": "Google 。",
        "time": 1496681150745
    },
    {
        "_id": "59358ac3daea9d0a6c1d344d",
        "id": 105,
        "tittle": "黄涛",
        "value": "验。",
        "time": 1496681150746
    },
    {
        "_id": "59358ac3daea9d0a6c1d344e",
        "id": 106,
        "tittle": "黄涛",
        "value": "Google 在新加坡组建工程中心时就曾说过:新加坡是最能给互联网带来「新的十亿用户」的国家。除了 Google、Facebook、",
        "time": 1496681150747
    }
]}

that's it!