/*
根据field获取gridcompColumn对象
960977
function getColumnByField(field) {
    for (var i = 0; i < this.gridCompColumnArr.length; i++) {
        if (this.gridCompColumnArr[i].options.field == field) {
            return this.gridCompColumnArr[i];
        }
    }
    for (var i = 0; i < this.gridCompColumnFixedArr.length; i++) {
        if (this.gridCompColumnFixedArr[i].options.field == field) {
            return this.gridCompColumnFixedArr[i];
        }
    }

    return null;
}
545706
private void validateDataPerWrite() throws WriteExcelException {
        //修正数据,并校验
        if (CollectionUtils.isEmpty(this.properties)) {
            if (CollectionUtils.isEmpty(this.datas)) {
                //此种情况下被写入数据不能为空,因为默认会根据datas去自动获取需要被写入的属性
                throw new WriteExcelException("datas为空,请检查数据");
            }
            T data = this.datas.get(0);
            this.setProperties(data instanceof Map ? ((Map) data).keySet() : CommonUtils.toMap(data).keySet());
        }
        if (CollectionUtils.isNotEmpty(this.excludeProps)) {
            //若设置了排除元素,先将元素排除
            this.properties.removeAll(this.excludeProps);
        }
        if (CollectionUtils.isEmpty(this.properties)) {
            throw new WriteExcelException("properties为空!");
        }
        if (this.isWriteTitle && CollectionUtils.isEmpty(this.titles)) {
            this.setTitles(this.properties);
        }
        if (this.isWriteTitle && this.properties.size() != this.titles.size()) {
            throw new WriteExcelException("属性与标题列数不一致");
        }
        if (XLSX == this.excelType && this.properties.size() > XLSX_COLUMN_MOST) {
            throw new WriteExcelException(String.format("列数不得超过最大值%d", XLSX_COLUMN_MOST));
        }
        if (XLS == this.excelType && this.properties.size() > XLS_COLUMN_MOST) {
            throw new WriteExcelException(String.format("列数不得超过最大值%d", XLS_COLUMN_MOST));
        }
        if (this.defaultCellStyle == null) {
            this.defaultCellStyle = this.workbook.createCellStyle();
            this.defaultCellStyle.setFont(this.workbook.createFont());
            this.defaultCellStyle.setAlignment(HorizontalAlignment.CENTER);
            this.defaultCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        }
        if (this.isWriteTitle && this.defaultTitleCellStyle == null) {
            this.defaultTitleCellStyle = this.workbook.createCellStyle();
            Font font = this.workbook.createFont();
            font.setBold(true);
            font.setFontHeightInPoints((short) 16);
            this.defaultTitleCellStyle.setFont(font);
            this.defaultTitleCellStyle.setAlignment(HorizontalAlignment.CENTER);
            this.defaultTitleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        }
        if (this.handleCellValue != null) {
            this.map = new HashMap<>(2);
        }
    }
1064797
public Object getColumnValue(int iColumnIndex, int iEditMode)
    {
        Convert fieldInfo = this.getFieldInfo(iColumnIndex);
        if (fieldInfo != null)
            return fieldInfo.getString();
        return Constants.BLANK;
    }
72522
public void fieldToData(ComponentCache componentCache, int iRowIndex, int iColumnIndex)
    {
        if (componentCache.m_rgcompoments[iColumnIndex] != null)
        {
            Object object = this.getModel().getValueAt(iRowIndex, iColumnIndex);
            String string = "";
            if (object != null)
                string = object.toString();
            if (componentCache.m_rgcompoments[iColumnIndex] instanceof JTextComponent)
                ((JTextComponent)componentCache.m_rgcompoments[iColumnIndex]).setText(string);
            else if (componentCache.m_rgcompoments[iColumnIndex] instanceof JCheckBox)
            {
                boolean bIsSelected = false;
                if (string != null) if (string.equals("1"))
                    bIsSelected = true;
                ((JCheckBox)componentCache.m_rgcompoments[iColumnIndex]).setSelected(bIsSelected);
            }
        }
    }
766019
@Override
    public void configFields(Configuration conf, String[] fields) 
            throws IllegalArgumentException, IOException {
        if (null != fields) {
            super.configFields(conf, fields);
        } else {
            throw new IOException("Fields not defined");
        }
        
        datatypeMap = new HashMap<String,ColumnDataType>();
        for (String s: fields) {
            datatypeMap.put(s, ColumnDataType.STRING);
        }
        String list = conf.get(ConfigConstants.CONF_DELIMITED_DATA_TYPE);
        if (list == null) {
            return;
        }
        String pairs[] = list.split(",");
        for (int i = 0; i < pairs.length; i += 2) {
            String colName = pairs[i].trim();
            String colDataType = pairs[i+1].trim();
            if (!datatypeMap.containsKey(colName)) {
                throw new IllegalArgumentException("Column name " + colName + " not found.");
            }
            if ("Number".equalsIgnoreCase(colDataType)) {
                datatypeMap.put(colName, ColumnDataType.NUMBER);
            } else if ("Boolean".equalsIgnoreCase(colDataType)) {
                datatypeMap.put(colName, ColumnDataType.BOOLEAN);
            } else if (!"String".equalsIgnoreCase(colDataType)) {
                throw new IllegalArgumentException("Unsupported column data type " + colDataType);
            }
        }
    }
1035718
public function getColumnMetadata($gridField, $column)
    {
        if ($column === self::CHECKBOX_COLUMN) {
            $title = _t('GridFieldMultiSelect.SelectAllVisibleRows', 'Select all visible rows');
            return array(
                'title' => '<input class="multiselect-all no-change-track" type="checkbox"
								title="' . htmlentities($title) . '">',
            );
        }
    }
1101616
private static String toColumnName(String fieldName) {
        int lastDot = fieldName.indexOf('.');
        if (lastDot > -1) {
            return fieldName.substring(lastDot + 1);
        } else {
            return fieldName;
        }
    }
75089
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Style Fields:
        
        $style = [];
        
        // Create Column Span Field:
        
        if (self::framework()->useColumnSpan()) {
            
            $style[] = ViewportsField::create(
                'Span',
                $this->fieldLabel('Span'),
                $this->getColumnSpanOptions()
            );
            
        }
        
        // Create Column Offset Field:
        
        if (self::framework()->useColumnOffset()) {
            
            $style[] = ViewportsField::create(
                'Offset',
                $this->fieldLabel('Offset'),
                $this->getColumnOffsetOptions()
            );
            
        }
        
        // Add Style Fields to Tab:
        
        if (!empty($style)) {
            
            $fields->addFieldToTab(
                'Root.Style',
                FieldSection::create(
                    'ColumnStyle',
                    $this->fieldLabel('ColumnStyle'),
                    $style
                )
            );
            
        }
        
        // Create Options Fields:
        
        $fields->addFieldToTab(
            'Root.Options',
            FieldSection::create(
                'ColumnOptions',
                $this->fieldLabel('ColumnOptions'),
                [
                    CheckboxField::create(
                        'Sidebar',
                        $this->fieldLabel('Sidebar')
                    ),
                    CheckboxField::create(
                        'HideEmpty',
                        $this->fieldLabel('HideEmpty')
                    ),
                    CheckboxField::create(
                        'EdgeToEdge',
                        $this->fieldLabel('EdgeToEdge')
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
1358701
function () {
		var columns = this.columns,
			col = columns.length, 
			row,
			val,
			floatVal,
			trimVal,
			dateVal;
			
		while (col--) {
			row = columns[col].length;
			while (row--) {
				val = columns[col][row];
				floatVal = parseFloat(val);
				trimVal = this.trim(val);

				/*jslint eqeq: true*/
				if (trimVal == floatVal) { // is numeric
				/*jslint eqeq: false*/
					columns[col][row] = floatVal;
					
					// If the number is greater than milliseconds in a year, assume datetime
					if (floatVal > 365 * 24 * 3600 * 1000) {
						columns[col].isDatetime = true;
					} else {
						columns[col].isNumeric = true;
					}					
				
				} else { // string, continue to determine if it is a date string or really a string
					dateVal = this.parseDate(val);
					
					if (col === 0 && typeof dateVal === 'number' && !isNaN(dateVal)) { // is date
						columns[col][row] = dateVal;
						columns[col].isDatetime = true;
					
					} else { // string
						columns[col][row] = trimVal === '' ? null : trimVal;
					}
				}
				
			}
		}
	}
295620
function basicSortRows(field, sortType) {
    var oThis = this,
        dataType = "";
    if (field) {
        dataType = this.gridComp.getColumnByField(field).options.dataType;
    }
    this.rows = new Array();
    this.groupRows = new Array();
    if (this.options.values) {
        $.each(this.options.values, function (i) {
            var rowObj = {};
            rowObj.value = this;
            rowObj.valueIndex = i;
            oThis.rows.push(rowObj);
            oThis.gridComp.getGroupIndex(this, i, rowObj);
            oThis.rows = oThis.getGroupRows();
        });
    }
}
851999
@SuppressWarnings("rawtypes")
    private static Field getDeclaredField(Class clazz, String fieldName) throws NoSuchFieldException {
        Assert.notNull(clazz);
        Assert.hasText(fieldName);
        for (Class superClass = clazz; superClass != Object.class; superClass = superClass.getSuperclass()) {
            try {
                return superClass.getDeclaredField(fieldName);
            } catch (NoSuchFieldException e) {
                // Field不在当前类定义,继续向上转型
            }
        }
        throw new NoSuchFieldException("No such field: " + clazz.getName() + '.' + fieldName);
    }
68002
public function getCMSFields()
    {
        // Create Field Tab Set:
        
        $fields = FieldList::create(TabSet::create('Root'));
        
        // Define Placeholder:
        
        $placeholder = _t(__CLASS__ . '.DROPDOWNSELECT', 'Select');
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                DropdownField::create(
                    'PageClass',
                    $this->fieldLabel('PageClass'),
                    $this->getPageClassOptions()
                )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder),
                DropdownField::create(
                    'MyTemplateID',
                    $this->fieldLabel('MyTemplateID'),
                    Template::get()->map()
                )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder),
                DropdownField::create(
                    'MyLayoutID',
                    $this->fieldLabel('MyLayoutID'),
                    Layout::get()->map()
                )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder)
            ]
        );
        
        // Create Grid Field Config:
        
        $spansConfig = GridFieldConfig_RecordEditor::create();
        
        // Obtain Edit Form Component:
        
        $editComponent = $spansConfig->getComponentByType(GridFieldDetailForm::class);
        
        // Define Edit Form Callback:
        
        $editComponent->setItemEditFormCallback(function ($form, $itemRequest) {
            
            // Define Column Options:
            
            $form->Fields()->dataFieldByName('ColumnID')->setSource($this->getColumnOptions());
            
        });
        
        // Create Column Spans Grid Field:
        
        $spans = GridField::create(
            'ColumnSpans',
            $this->fieldLabel('Spans'),
            $this->ColumnSpans(),
            $spansConfig
        );
        
        // Create Column Spans Tab:
        
        $fields->findOrMakeTab('Root.ColumnSpans', $this->owner->fieldLabel('Spans'));
        
        // Add Grid Field to Column Spans Tab:
        
        $fields->addFieldToTab('Root.ColumnSpans', $spans);
        
        // Extend Field Objects:
        
        $this->extend('updateCMSFields', $fields);
        
        // Answer Field Objects:
        
        return $fields;
    }
616755
function createFormContentRows() {
    var oThis = this,
        htmlStr = "";
    // 遍历生成所有行
    if (this.dataSourceObj.rows) {
        htmlStr += '<tbody role="rowgroup" id="' + this.options.id + '_form_content_tbody">';
        $.each(this.dataSourceObj.rows, function () {
            htmlStr += '<tr role="row"><td role="rowcell">';
            var value = this.value;
            $.each(oThis.gridCompColumnArr, function () {
                var f = this.options.field,
                    t = this.options.title,
                    v = $(value).attr(f);
                htmlStr += '<div>' + t + ':</div>';
                htmlStr += '<div>' + v + '</div>';
            });
            htmlStr += '</td></tr>';
        });
        htmlStr += '</tbody>';
    }
    return htmlStr;
}
1074826
private String convertFieldValue(final Field field,
                                     final ExportContainer container) {
        final boolean isArray2D = (container.getType() == FieldContainer.Type.ARRAY_2D);
        if (field.getType().equals(String.class)) {
            return wrapWithComma(container.getExportValue());
        } else if (isTypeTimestampConvertible(field)) {
            return wrapWithComma(String.valueOf(convertFieldValueToTimestamp(field, container)));
        } else if (container.getType() == FieldContainer.Type.ARRAY
                || isArray2D
                || container.getType() == FieldContainer.Type.COLLECTION) {

            final Class<?> componentType = extractType(container.getType(), field);
            final String sqlType = dataTypes.getOrDefault(componentType, "VARCHAR");
            final String result = (sqlType.equals("VARCHAR") || sqlType.equals("CHAR"))
                    ? container.getExportValue().replace("[", "{\"").replace("]", "\"}").replace(",", "\",\"").replace(" ", "")
                    : container.getExportValue().replace("[", "{").replace("]", "}");
            return wrapWithComma(result);
        }

        return container.getExportValue();
    }
352464
protected function buildColumnDispatch()
    {
        $this->columnDispatch = array();

        foreach ($this->getComponents() as $item) {
            if ($item instanceof GridField_ColumnProvider) {
                $columns = $item->getColumnsHandled($this);

                foreach ($columns as $column) {
                    $this->columnDispatch[$column][] = $item;
                }
            }
        }
    }
386647
private void writeColumn(String columnName, Object value) throws XMLStreamException {
        xmlStreamWriter.writeStartElement("column");
        xmlStreamWriter.writeAttribute("name", columnName);
        String stringValue = null;
        if (value instanceof CompositeObject) {
            CompositeObject descriptor = (CompositeObject) value;
            LanguageElement elementValue = LanguageHelper.getLanguageElement(descriptor);
            if (elementValue != null) {
                xmlStreamWriter.writeStartElement("element");
                xmlStreamWriter.writeAttribute("language", elementValue.getLanguage());
                xmlStreamWriter.writeCharacters(elementValue.name());
                xmlStreamWriter.writeEndElement(); // element
                SourceProvider sourceProvider = elementValue.getSourceProvider();
                stringValue = sourceProvider.getName(descriptor);
                String sourceFile = sourceProvider.getSourceFile(descriptor);
                Integer lineNumber = sourceProvider.getLineNumber(descriptor);
                if (sourceFile != null) {
                    xmlStreamWriter.writeStartElement("source");
                    xmlStreamWriter.writeAttribute("name", sourceFile);
                    if (lineNumber != null) {
                        xmlStreamWriter.writeAttribute("line", lineNumber.toString());
                    }
                    xmlStreamWriter.writeEndElement(); // sourceFile
                }
            }
        } else if (value != null) {
            stringValue = ReportHelper.getLabel(value);
        }
        xmlStreamWriter.writeStartElement("value");
        xmlStreamWriter.writeCharacters(stringValue);
        xmlStreamWriter.writeEndElement(); // value
        xmlStreamWriter.writeEndElement(); // column
    }
478265
public function getIndexGridColumns($model, $fields)
    {
        /** @var ActiveController $controller */
        $controller = $this->controller;
        $actionColumn = new ActionColumn();
        $actionColumn->buttonOptions['class'] = 'operation-button';
        $extraColumns = [
            [
                'class'         => \yii\grid\ActionColumn::className(),
                'headerOptions' => ['class' => 'column-action'],
                'controller'    => Yii::$app->crudModelsMap[$model::className()],
                'template'      => '{update} {delete} {toggle}', // {view} removed because representing column is linked
                'buttons' => [
                    'view'   => function ($url, $model, $key) use ($controller, $actionColumn) {
                        if (!$controller->hasAccess('read', $model)) {
                            return null;
                        }

                        return $actionColumn->buttons['view']($url, $model, $key);
                    },
                    'update' => function ($url, $model, $key) use ($controller, $actionColumn) {
                        if (!$controller->hasAccess('update', $model)) {
                            return null;
                        }

                        return $actionColumn->buttons['update']($url, $model, $key);
                    },
                    'delete' => function ($url, $model, $key) use ($controller, $actionColumn) {
                        if (!$controller->hasAccess('delete', $model)) {
                            return null;
                        }

                        return $actionColumn->buttons['delete']($url, $model, $key);
                    },
                    'toggle' => function ($url, $model, $key) use ($controller, $actionColumn) {
                        /** @var \yii\db\ActiveRecord $model */
                        if ($model->getBehavior('toggable') === null || !$controller->hasAccess('delete', $model)) {
                            return null;
                        }

                        $enabled = $model->isEnabled();
                        $icon    = '<span class="glyphicon glyphicon-'.($enabled ? 'ban' : 'reply').'"></span>';
                        $options = array_merge([
                            'title'       => $enabled ? Yii::t('app', 'Disable') : Yii::t('app', 'Enable'),
                            'aria-label'  => $enabled ? Yii::t('app', 'Disable') : Yii::t('app', 'Enable'),
                            'data-pjax'   => '0',
                        ], $enabled ? [
                            'data-confirm' => Yii::t('app', 'Are you sure you want to disable this item?'),
                        ] : [], $actionColumn->buttonOptions);
                        return \yii\helpers\Html::a($icon, $url, $options);
                    },
                ],
            ],
        ];
        if ($this->useSerialColumn) {
            $extraColumns[] = [
                'class'         => \yii\grid\SerialColumn::className(),
                'headerOptions' => ['class' => 'column-serial'],
            ];
        }
        if ($this->useCheckboxColumn) {
            //$classParts = explode('\\', $this->modelClass);
            $extraColumns[] = [
                'class'         => \yii\grid\CheckboxColumn::className(),
                'headerOptions' => ['class' => 'column-checkbox'],
                'multiple'      => true,
                //'name'          => end($classParts).'[]',
            ];
        }

        return array_merge($extraColumns, static::getGridColumns($model, $fields));
    }