In DynamicForm you create the property _rowTable in items.
Could you make this property readable in development mode?
Could you make this property readable in development mode?
getRowTable = function () { return this.items?._rowTable ? this.items._rowTable.map(row => row.slice()) : null; }
import ISC_CLASS from "../ISC_CLASS"; import { DynamicForm } from 'smartclient-pro/react'; let isc = window.isc; class CustomForm extends DynamicForm { static ISC_CLASS_NAME = "CustomForm"; static IS_CLASS = true; static PROPERTY_TYPES = {}; static init = function () { this.Super("init", arguments); for (const field of this.getFields()) { if (field.width === "*") { field.calcWidth = true; } } }; static buildRowItems = function (create) { if (!this.isVisible()) return; if (!create && this.rowsTable) return this.rowsTable; var items = this.getItems(); var numCols = this.numCols || 2; var rowTable = []; var currentRow = 0; var currentCol = 0; for (var itemNum = 0; itemNum < items.length; itemNum++) { var item = items[itemNum]; if (!item.isVisible()) continue; var itemCols = item.getColSpan ? item.getColSpan() : (item.colSpan || 1); var itemRows = item.getRowSpan ? item.getRowSpan() : (item.rowSpan || 1); if (!itemCols || !itemRows) continue; if (!isNaN(itemCols)) itemCols = parseInt(itemCols); if (itemCols == null) itemCols = 1; if (!isNaN(itemRows)) itemRows = parseInt(itemRows); if (itemRows == null) itemRows = 1; var requiredCols = (itemCols === "*") ? 1 : itemCols; if (item.showTitle) { requiredCols += (item.getTitleColSpan ? item.getTitleColSpan() : 1); if (itemCols !== "*") itemCols += (item.getTitleColSpan ? item.getTitleColSpan() : 1); } var startRow = (item.isStartRow ? item.isStartRow() : item.startRow); var endRow = (item.isEndRow ? item.isEndRow() : item.endRow); var placeRow = null, placeCol = null; if (item._startRow = (currentCol >= numCols || (startRow && currentCol != 0))) { currentRow++; currentCol = 0; } if (currentRow < rowTable.length) { for (; currentRow < rowTable.length; currentRow++) { var rowSlots = rowTable[currentRow]; if (!rowSlots) break; for (; currentCol < numCols; currentCol++) { if (rowSlots[currentCol] != null) continue; for (var j = currentCol; j < numCols; j++) { if (rowSlots[j] != null) break; if ((j - currentCol) + 1 >= requiredCols) { placeRow = currentRow; placeCol = currentCol; break; } } if (placeCol != null) break; } if (placeCol != null) break; currentCol = 0; item._startRow = true; } } if (placeCol == null) { placeRow = currentRow; placeCol = 0; item._startRow = true; } currentCol = placeCol; if (itemCols === "*") itemCols = numCols - currentCol; if (!isc.isA.Number(itemRows)) itemRows = 1; for (var r = currentRow; r < currentRow + itemRows; r++) { if (!rowTable[r]) rowTable[r] = []; for (var c = currentCol; c < currentCol + itemCols; c++) { rowTable[r][c] = item; } } currentCol += itemCols; if (endRow) currentCol = numCols; } var rows = rowTable.map(function (cells) { var unique = []; for (var i = 0; i < cells.length; i++) { var it = cells[i]; if (it && !unique.contains(it)) unique.push(it); } return unique; }); return this.rowsTable = rows; } static drawn = function () { this.setItemsWidths(); }; static resized = function () { this.setItemsWidths(); }; static setItemWidth(item, width) { if (item.getWidth() !== width) { item.setWidth(width); const canvas = item.canvas; if (canvas) { canvas.setWidth(width); } } } static setItemsWidths() { setTimeout(() => { const rowsTable = this.buildRowItems(); if (!rowsTable) return; const patternWidth = this.getInnerContentWidth(); if (this.prevWidth !== patternWidth) { this.prevWidth = patternWidth; for (const rowItems of rowsTable) { const starItems = []; let fixedWidth = this.cellPadding * (rowItems.length + 1); for (const item of rowItems) { if (item.calcWidth) { starItems.push(item); } } const starWidth = starItems.length > 0 ? Math.floor((patternWidth - fixedWidth) / starItems.length) : 0; for (const item of rowItems) { if (starItems.includes(item)) { this.setItemWidth(item, starWidth); } } } } }, 0); } } ISC_CLASS.registerClass(CustomForm, DynamicForm); export default CustomForm;
Comment