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 🙏

© 2025 – Pkg Stats / Ryan Hefner

k2-ag-grid-addons

v1.1.0

Published

ag-grid plugin for k2

Readme

React Component Boilerplate

#1.组件 ###ControllBtn,DateFormat, PageNumChange, SearchFilter, TagCellRender, TipTemplate, TopPageChange, CopyOrClick, TableResize, EditCell, StopEdit, PaginationInput(待续...)

EditCell, StopEdit

使用方法

一般配合ControllBtn使用
eg:在ControllBtn参数data
const data = [
      {innerHTML: '修改', href: 'javascript:;', onclick: (function (params) {
        const currentVal = EditCell(params, 'projName')
        console.log(currentVal)
      }).bind(this)},
      {innerHTML: '取消', href: 'javascript:;', onclick: function (params) {
        StopEdit(params, 'projName', 'test')
      }}
	  EditCell 第二个参数代表要修改的列的field值,点击修改按钮则修改了按钮所在行的projName列对应的cell,且EditCell返回当前修改的cell的内容
	  StopEdit 停止修改,第二个参数和EditCell的第二个参赛意义一样,第三个参数可传可不传,如传,表示停止编辑后,当前的cell显示的内容

###ControllBtn: 使用方法:

 import { ControllBtn } from 'ag-grid-addons'
在columnDefs中cellRender: function (params) {
  return ControllBtn(params, data)
}
eg: data = [
  {innerHTML: 'test1', href: 'javascript:;', onclick: function () { console.log(1111) }},
  {innerHTML: 'test2', href: 'javascript:;', onclick: function () { console.log(222) }}
]
btn的载体为a标签,所以其中定义的属性为a标签的属性

###DateFormat: 使用方法:

import { DateFormat } from 'ag-grid-addons'
  在columnDefs中cellRender: DateFormat(待优化)
  依赖moment.js

###PageNumChange: 使用方法:

import { PageNumChange } from 'ag-grid-addons'
      此为改变ag-grid表格的显示条数的组件
      eg: <PageNumChange pagesize={[10, 20, 50]} onChange={this.onChange} />

      pagesize为一个数组,数组的第一元素为默认选择
      onChange回调,获取的为当前选择的value

###SearchFilter: 使用方法:

import { SearchFilter } from 'ag-grid-addons'
     在columnDefs中filter: SearchFilter

     为k2自定义的搜索组件,目前不支持后台过滤(后期添加)

###TagCellRender: 使用方法:

import { TagCellRender } from 'ag-grid-addons'
    在columnDefs中cellRender: function (params) {
      return TagCellRender(params, callback)
    }
    eg: callback = (value) => {
      console.log(value)
    }
    注意: 须在表格中展示的数据,即params.value为数组,
    可将其元素展示为标签,并支持Ctrl + click选中,并返回一个选中标签的内容的
    数组,支持翻页后返回仍被选中的状态。

###TipTemplate: 使用方法:

 import { TipTemplate } from 'ag-grid-addons'
     在columnDefs中cellRender: function (params) {
       return TipTemplate(params, callback)
     }
     eg: callback = (params) => {
       let tips = {}
       if ((params.rowIndex % 2) === 0) {
         tips.type = 'success'
       } else if ((params.rowIndex % 3) === 0){
         tips.type = 'warning'
       } else if ((params.rowIndex % 5) === 0){
         tips.type = 'error'
       } else {
         tips.type = 'fail'
       }
       tips.message = params.value
       tips.value = params.value
       return tips
     }
     注意:设置提示信息和提示类型 必须return一个数据, 数据格式{type:'success|fail|error|waring|info', message: 'sss', value: 'test'}

###CopyOrClick: 使用方法:

import { CopyOrClick } from 'ag-grid-addons'
    在所用组件中的constructor () {
      super()
      this.CopyOrClick = CopyOrClick.bind(this)
    }
    eg: onGridReady (params) {
      this.api = params.api
      this.columnApi = params.columnApi
      this.CopyOrClick(this.rowClick)
    }
    作用:用于ag-grid行单击发生跳转所用,单击跳转,滑动复制表格内容时不执行click

###TableResize: 使用方法:

 import { TableResize } from 'ag-grid-addons'
   在所用组件中的constructor () {
     super()
     this.TableResize = TableResize.bind(this)
   }
   eg: onGridReady (params) {
     this.api = params.api
     this.columnApi = params.columnApi
     this.TableResize()
   }
   作用:用于ag-grid在改变浏览器大小时自适应,前提条件是ag-grid的gridOption设置enableColResize=true,且columnDefs中的不是所有列都包含suppressSizeToFit:true,
   如果需要在ag-grid加载时就进行自适应,请在gridOption中设置
   onModelUpdated: () => {
     if (this.api) {
       this.api.sizeColumnsToFit()
     }
   }

###PaginationInput: 介绍:介于ag-grid更新太快,且分页区功能不太适合项目,所以单独独立出一个分页功能 使用方法: import { PaginationInput } from 'ag-grid-addons' 。。。。 具体使用方法请参考项目example中的app ###(未完,待续....) Build Status Dependency Status devDependency Status

Minimal React component boilerplate with Babel 6, Webpack, hot module replacement via babel-plugin-react-transform, Flow, tests with Tape and eslint-friendly.

Inspired by Dan Abramov's library boilerplate

How-to

$ npm install

$ npm run dev

navigate to localhost:8080

Considerations

You might want to tune .babelrc and webpack.config based on your needs.

Why's

  • Why not to use npm scripts over webpack CLI to run a dev server? — that's why

  • Why so fancy import works import Component from Component? — checkout the aliases in webpack config.

Anything?

Feedback appreciated!