Permalink
Browse files

fix: IUAPDESIGN-69:营销物业管理:u-meta定义方式需要支持指定数据行

  • Loading branch information...
liuyk
liuyk committed Oct 18, 2016
1 parent 19beaf6 commit b40b214f1dd8f64e39c58e8d6a938546e07e9017
Showing with 34 additions and 2 deletions.
  1. +3 −1 js/dataTable/indexDataTable.js
  2. +31 −1 js/dataTable/ref.js
@@ -104,7 +104,8 @@ import {
ref,
refMeta,
refRowMeta,
refEnable
refEnable,
refByRow
} from './ref';
import {
@@ -300,6 +301,7 @@ DataTable.prototype.ref= ref;
DataTable.prototype.refMeta= refMeta;
DataTable.prototype.refRowMeta= refRowMeta;
DataTable.prototype.refEnable= refEnable;
DataTable.prototype.refByRow= refByRow;
//row
DataTable.prototype.setRows= setRows;
View
@@ -18,6 +18,7 @@ const refSelectedRows = function () {
})
}
/**
* 绑定字段值
* @param {Object} fieldName
@@ -46,6 +47,34 @@ const ref = function (fieldName) {
})
}
const refByRow = function(obj){
var fieldName = obj.fieldName;
this.createField(fieldName);
if (!this.valueChange[fieldName])
this.valueChange[fieldName] = ko.observable(1);
return ko.pureComputed({
read: function () {
this.valueChange[fieldName]();
this.currentRowChange();
var row;
if(obj.index > -1)
row = this.getRow(obj.index)
if (row) {
return row.getChildValue(fieldName)
}
else
return ''
},
write: function (value) {
var row;
if(obj.index > -1)
row = this.getRow(obj.index)
if (row)
row.setChildValue(fieldName, value);
},
owner: this
})
}
/**
* 绑定字段属性
* @param {Object} fieldName
@@ -111,5 +140,6 @@ export {
ref,
refMeta,
refRowMeta,
refEnable
refEnable,
refByRow,
}

0 comments on commit b40b214

Please sign in to comment.