谷神前端组件增强:子列表

reDrawRow
// // 刷新数据行显示:子列表编辑失去焦点
detailTable.reDrawRow()
sumDetailTableField
/**
 * sumDetailTableField
 * 统计子列表字段域:求和。
 * 
 * @param detailTable:子列表。
 * @param field:字段域。
 * 
 * @return sum:和。
 * 
 */
function sumDetailTableField (detailTable, field) {
	return detailTable.getData().reduce((sum, row) => {
		return gUtil.precise(sum, row[field], '+')
	}, 0)
}
batchSetDataValue
/**
 * batchSetDataValue
 * 设置表格fieldName列的数据。
 * 
 * @param detailTable:子列表。
 * @param fieldName:指定字段。
 * @param value:数据。
 * 
 * @return void
 * 
 */
function batchSetDataValue (detailTable, fieldName, value) {
	detailTable.getData().forEach(row => {
		detailTable.setDataValue(row[detailTable.BILL_BATCH], fieldName, value)
	})
}
// 设置表格fieldName列的数据。
detailTable.getData().forEach(row => {
	detailTable.setDataValue(row[detailTable.BILL_BATCH], fieldName, value)
})
cleanColumn
/**
 * cleanColumn
 * 清理列
 * 
 * @param detailTable:子列表。
 * @param fieldNames:要清理的列。
 * 
 * @return void
 * 
 */
function cleanColumn (detailTable, ...fieldNames) {
	fieldNames.forEach(fieldName => {
		detailTable.setColumnVisible(fieldName, false)
		// 设置表格fieldName列的数据。
		detailTable.getData().forEach(row => {
			detailTable.setDataValue(row[detailTable.BILL_BATCH], fieldName, null)
		})
	})
}
子列表input控制
// 创建一个新的MutationObserver实例并传入回调函数  
const observer = new MutationObserver((mutations, observer) => {  
    // 遍历所有变化  
    for (let mutation of mutations) {  
        // 检查是否有新的input元素被添加  
        if (mutation.type === 'childList') {  
            mutation.addedNodes.forEach(function(node) {  
                // 检查节点是否是input元素  
                if (node.nodeType === Node.ELEMENT_NODE && node.tagName.toLowerCase() === 'input') {
					if (node.parentNode && node.parentNode.getAttribute('col-id') == 'col-id') {
						// 设置maxlength
						node.setAttribute('maxlength', '10')
					}
                }  
            })
        }  
    }  
})

// 以上面的配置开始观察目标节点  
observer.observe(detailTable.findHtmlDocument('div.ag-center-cols-container')[0], {childList: true, subtree: true})
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值