Skip to content

Commit

Permalink
[changed] change the params for addSubRow
Browse files Browse the repository at this point in the history
  • Loading branch information
qili.taoqili committed Mar 11, 2019
1 parent cee8881 commit 60e8bed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ $ npm start
* addEmptyRowFromTop(): 从顶部添加一个空的新行。
* addRow(rowData): 以指定数据添加一个新行。
* addRowFromTop(rowData): 以指定数据从顶部添加一个新行。
* addSubRow(rowData, jsxid, cb): 树形表格模式下从底部插入一个子树节点行
* addSubRomFromTop(rowData, jsxid, cb): 树形表格模式下从顶部插入一个子树节点行
* addSubRow(subRowData, rowData, cb): 树形表格模式下从底部插入一个子树节点行
* addSubRomFromTop(subRowData, rowData, cb): 树形表格模式下从顶部插入一个子树节点行
* delRow(rowData): 删除一个新行。
* editRow(rowData): 使指定的行切换到编辑模式。
* editAllRow(): 使所有行切换到编辑模式。
Expand Down
8 changes: 4 additions & 4 deletions demo/TreeGridDemo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Demo extends React.Component {
collapseNum: 5,
actions: [
{
title: '新增',
title: '新增子行',
callback: (rowData) => {
this.table.addSubRow({
"id": `${setTimeout(0)}`,
Expand All @@ -109,7 +109,7 @@ class Demo extends React.Component {
"birthDate": "2birthDate3",
"country": `country_${setTimeout(0)}`,
"city": "2city3"
}, rowData.jsxid, () => {
}, rowData, () => {
console.log(this.table.getData())
})
}
Expand Down Expand Up @@ -208,7 +208,7 @@ class Demo extends React.Component {
collapseNum: 5,
actions: [
{
title: '新增',
title: '新增子行',
callback: (rowData) => {
this.table.addSubRow({
"id": `${setTimeout(0)}`,
Expand All @@ -220,7 +220,7 @@ class Demo extends React.Component {
"birthDate": "2birthDate3",
"country": `country_${setTimeout(0)}`,
"city": "2city3"
}, rowData.jsxid, () => {
}, rowData, () => {
console.log(this.table.getData())
})
}
Expand Down
10 changes: 6 additions & 4 deletions src/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ function addRowFromTop(rowData, cb) {
this.insertRecords(rowData, true, cb);
}

function addSubRow(rowData, jsxid, cb) {
function addSubRow(subRowData, rowData, cb) {
const { jsxid } = rowData
if (jsxid >= 0 && this.props.renderModel === 'tree') {
this.insertRecords(rowData, false, cb, jsxid)
this.insertRecords(subRowData, false, cb, jsxid)
}
}

function addSubRowFromTop(rowData, jsxid, cb) {
function addSubRowFromTop(subRowData, rowData, cb) {
const { jsxid } = rowData
if (jsxid >= 0 && this.props.renderModel === 'tree') {
this.insertRecords(rowData, true, cb, jsxid)
this.insertRecords(subRowData, true, cb, jsxid)
}
}

Expand Down

0 comments on commit 60e8bed

Please sign in to comment.