C1FlexGrid AllowMerging Nodes is difference

Posted by: dung.itcdt on 2 August 2023, 9:54 pm EST

    • Post Options:
    • Link

    Posted 2 August 2023, 9:54 pm EST - Updated 2 August 2023, 10:00 pm EST

    In the old version (2016.1) when I set AllowMerging=Nodes, the cells of the node line will be merged until the end.

    But in the new version (2023v1), the node line is merged according to the width of the content.

    Is this a feature or not? Now I want to merge everything like the old version, how do I do that?

    Thanks, Best Regard.

  • Posted 3 August 2023, 4:05 am EST

    Hi,

    Thank you for sharing the screenshots. Yes, this is the expected behavior in the latest version of C1FlexGrid i.e. the node cells are merged as per the space required by the text and not all the way to the end.

    To workaround this behavior, you can inherit the C1FlexGrid class and override the GetMergedRange method to manually return the range as per your merge condition. Please see the attached sample project showing a simple implementation of the same.

    Attachment: FlexGridNodeMerge.zip

    Best Regards,

    Kartik

  • Posted 7 August 2023, 4:32 am EST - Updated 7 August 2023, 4:32 am EST

    Hi,

    I has overrides GetMergedRange with this function and it working well. Thank for your support :slight_smile:

    [code]private CellRange getNodesRange(CellRange cellRange)

    {

    var _nTopRow = cellRange.r1;

    var _nLeftCol = cellRange.c1;

    var _cols = Cols;

            if (isDataEmpty(_nTopRow, _nLeftCol)
                && _nLeftCol > 0
                && _nLeftCol != _cols.Fixed
                && _nLeftCol != _cols.Fixed + _cols.Frozen
                && _cols[_nLeftCol - 1].Visible)
            {
                var _preCellRange = GetCellRange(_nTopRow, _nLeftCol - 1);
                _preCellRange = getNodesRange(_preCellRange);
    
                if (!_preCellRange.ContainsCol(_nLeftCol))
                    return cellRange;
    
                return _preCellRange;
            }
            else
            {
                if (!_cols[_nLeftCol].Visible)
                    return cellRange;
    
                object _data = GetData(_nTopRow, _nLeftCol);
                if (_data != null)
                {
                    var _type = _data.GetType();
                    if (_type != null && isNumericType(_type))
                        return cellRange;
                }
    
                var _nEndCol = _cols.Count - 1;
                if (_nLeftCol < _cols.Fixed)
                    _nEndCol = _cols.Fixed - 1;
                else if (_nLeftCol < _cols.Fixed + _cols.Frozen)
                    _nEndCol = _cols.Fixed + _cols.Frozen - 1;
    
                if (_nLeftCol < _nEndCol && isDataEmpty(_nTopRow, _nLeftCol + 1))
                {
                    int _nMaxWidth = int.MaxValue;
                    int _nColWidth = _cols[_nLeftCol].WidthDisplay;
    
                    while (_nColWidth < _nMaxWidth && cellRange.c2 < _nEndCol)
                    {
                        if (!isDataEmpty(_nTopRow, cellRange.c2 + 1))
                            return cellRange;
    
                        cellRange.c2++;
                        _nColWidth += _cols[cellRange.c2].WidthDisplay;
                    }
                }
    
                return cellRange;
            }
        }[/code]
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels