New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uxcore-table

Package Overview
Dependencies
Maintainers
1
Versions
299
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uxcore-table

table ui component for react

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

uxcore-table


uxcore table, will including checkbox, edit text field, column pick etc

How to run

$ git clone https://github.com/uxcore/uxcore-table
$ cd uxcore-table
$ npm install
$ gulp server

Best Practice


	let columns = [
        { dataKey: 'check', type: 'checkbox', disable: false}, // custom checkbox column, dataKey can be anyone, true means checked.
	    { dataKey: 'id', title: 'ID', width: 50,hidden:true},
	    { dataKey: 'country', title:'国家', width: 200,ordered:true},
	    { dataKey: 'city',title:'城市', width: 150,ordered:true },
	    { dataKey: 'firstName',title:"FristName" },  
	    { dataKey: 'lastName' ,title:"LastName"},
	    { dataKey: 'email',title:"Email",width: 200,ordered:true }
	];


	let rowSelection = {
      onSelect: function(record, selected, selectedRows) {
        console.log(record, selected, selectedRows);
      },
      onSelectAll: function(record, data) {
        console.log(record, data);
      }
    };

	renderProps={
        actionBar: {
           'new': function(type, actions){ alert(type); },  // type means 'new' in this line
           'import': function(type, actions){ alert(type); }, // actions contains all table's APIs, such as actions.addEmptyRow()
           'export': function(type, actions){ alert(type); }
        },
        fetchUrl:"http://localhost:3000/demo/data.json",
        jsxcolumns:columns,
        subComp:(<Table {...renderSubProps}  ref="subTable"/>),
        rowSelection: rowSelection
	},
	
	renderSubProps={
        jsxcolumns:columns,
        fetchUrl:"http://localhost:3000/demo/data.json",
        queryKeys:["dataKey","firstName"],
        onModifyRow: this.onModifyRow
	};

	<Table {...renderProps} />

Props

NameTypeRequireDefaultNote
jsxcolumnsarrayrequirednullcolumns config
widthnumberoptional1000table width
heightnumberoptional100%table height
showColumnPickerbooleanoptionaltrue
showPagerbooleanoptionaltrue
showHeaderbooleanoptionaltrue
headerHeightnumberoptional40
showMaskbooleanoptionaltrue
showSearchbooleanoptionalfalse
pageSizenumberoptional10
queryKeysarrayoptional[]in subComp mode, it tells parent what datas need to pass to child, like a filter, the parent will pass all his data to his child if queryKey is undefined
jsxdataobjectoptional-table data
fetchUrlstringoptional""dynamic get data from server
fetchParamsobjectoptional-in form-table mode, form will pass fetch params for table
actionBarobjectoptionalnullsee Usage to get
beforeFetchfunction(data, from)optionalnoopinvoked before the table fetch data, two params data and from, data is the one which will be passed as querys in ajax, from means where the fetch is invoked containing 3 preset values search,order & pagination.return the data you really want ajax to send.
processDatafunction(data)optionalnoopsometimes the data fetched via ajax is not the one which you or table want, you can use this method to change the data and return it to table. the param is the data which table is ready to use for rendering
addRowClassNamefunction(rowData)optionalnoopuser can use this to add className to the Row, in order to custom the specific row.
renderModelstringoptional'tree'render to tree model
levelsnumberoptional1tree model, default expand level number

Props you should not define by yourself

Parent will pass this props to his child

props namedefalut ValueNote
passedDatanullData passed from parent

Columns

Key NameRequireTypeNote
dataKeyrequiredstringuse key
titlerequiredstringcolumn display name
widthrequirednumber
hiddenoptionalboolean
orderoptionalbooleanneed order feature or not
typeoptionalstringcontaining 'money', 'card', 'cnmobile', 'checkbox' & 'action'
disableoptionalbooleandisable a column, now only support type 'checkbox'
actionsrequiredarraywhen type =='action', we need this attr
renderoptionalfunctionfor custom cell
beforeRenderoptionalfunctionfor custom cell data
fixedoptionalbooleanset the column fixed or not
delimiteroptionalstringdelimiter used in type 'money', 'card', 'cnmobile' formating

let columns = [
        { dataKey: 'check', type: 'checkbox', disable: false}, // custom checkbox column, dataKey can be anyone, true means checked.
        { dataKey: 'country', title:'国家', width: 200,ordered:true},
        { dataKey: 'city',title:'城市', width: 150,ordered:true },
        { dataKey: 'firstName',title:"FristName" },  
        { dataKey: 'lastName' ,title:"LastName", beforeRender: function(rowData){
        	//do logic , then return cell data
        	return 'abc';
        }},
        { dataKey: 'email',title:"Email",width: 200,ordered:true },
        { dataKey: 'action1', title:'操作1', width:100, type:"action",actions:{
            "编辑": function(rowData, actions) {
                me.refs.table.toggleSubComp(rowData);
            },
            "删除": function(rowData, actions) {	
                me.refs.table.delRow(rowData);
            }
         }},
        { dataKey: 'action', title:'链接', width:100,render: function(cellData,rowData){
           return <div><a href="#">{rowData.email}</a></div>
          }
        }
 ]

Rules

  • return data format here
   {
	"content":{
		"datas":[
			{	
				"id":'1'
				"grade":"grade1",
				"email":"email1",
				"firstName":"firstName1",
				"lastName":"lastName1",
				"birthDate":"birthDate1",
				"country":"country1",
				"city":"city1"
			}
			...
	
		],
		"currentPage":1,
		"totalCount":30
	},
	"success":true,
	"errorCode":"",
	"errorMsg":""
	}

the above the data format which server should send, if you pass data via jsxdata, you just need passed the content, like below

{
    "datas":[
        {   
            "id":'1'
            "grade":"grade1",
            "email":"email1",
            "firstName":"firstName1",
            "lastName":"lastName1",
            "birthDate":"birthDate1",
            "country":"country1",
            "city":"city1"
        }
        ...

    ],
    "currentPage":1,
    "totalCount":30
}

API

  • fetchData(from): call this method when you want the table to fetch Data via ajax again.
    • @param from {string} {optional}: the param will be passed to props.beforeFetch.
  • getData()
  • addEmptyRow()
  • addRow(rowData)
  • updataRow(rowData): used in inline edit
  • delRow(rowData)
  • toggleSubComp(rowData): show or hide sub comp

Keywords

FAQs

Package last updated on 27 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc