Full text filtering of the rows not working with custom columns

Posted by: mocanSergiu666 on 25 June 2018, 2:20 am EST

  • Posted 25 June 2018, 2:20 am EST

    The problem is that the highlighting of the text within the cells is happening, but the filtering itself of the rows doesn’t happen.

    Row view model:

    
    public class ProgressScheduleRowViewModel : ViewModel
        {
            public int RowRecordId { get; set; }
    
            public List<ProgressScheduleInfoCellViewModel> InfoCells { get; set; }
    
            public List<ProgressScheduleStepCellViewModel> StepCells { get; set; }
        }
    
    

    Grid configuration:

    
    ProgressScheduleFlexGrid.AutoGenerateColumns = false;
    ProgressScheduleFlexGrid.ItemsSource = new C1FilterCollectionView<ProgressScheduleRowViewModel>(ViewModel.Rows);
    
    

    Full text filter configuration:

    
    FullTextFilterBehavior fullTextFilterBehavior = new FullTextFilterBehavior();
    
                fullTextFilterBehavior.Attach(ProgressScheduleFlexGrid);
                fullTextFilterBehavior.FilterEntry = FilterTextField;
                fullTextFilterBehavior.HighlightColor = _fullTextFilterSelectedTextColor;
                fullTextFilterBehavior.MatchNumbers = true;
                fullTextFilterBehavior.Mode = FullTextFilterMode.WhileTyping;
                fullTextFilterBehavior.TreatSpacesAsAndOperator = true;
    
    

    Custom column addition:

    
    private void ConfigureFlexGridRecordIdInfoColumn(ProgressScheduleInfoColumnViewModel recordIdInfoColumnViewModel)
            {
                GridColumn recordIdInfoColumn = new ProgressScheduleRecordIdInfoColumn();
    
                ConfigureFlexGridColumn(ref recordIdInfoColumn, recordIdInfoColumnViewModel.Name, recordIdInfoColumnViewModel.Name, 100);
            }
    
    private void ConfigureFlexGridColumn(ref GridColumn gridColumn, string columnName, string columnHeader, GridLength width)
            {
                gridColumn.ColumnName = columnName;
                gridColumn.Header = columnHeader;
                gridColumn.HeaderHorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                gridColumn.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                gridColumn.IsVisible = true;
                gridColumn.Width = width;
                ProgressScheduleFlexGrid.Columns.Add(gridColumn);
            }
    
    

    Custom column definition:

    
    public class ProgressScheduleRecordIdInfoColumn : GridColumn
        {
            private const int _space = 5;
    
            protected override void BindCellContent(UIView cellContent, GridCellType cellType, GridRow row)
            {
                if (cellType == GridCellType.Cell)
                {
                    UILabel recordIdInfoCellContent = cellContent as UILabel;
    
                    recordIdInfoCellContent.Text = GetCellText(cellType, row);
                }
                else
                {
                    base.BindCellContent(cellContent, cellType, row);
                }
            }
    
            protected override UIView CreateCellContent(GridCellType cellType, object cellContentType, GridRow row)
            {
                if (cellType == GridCellType.Cell)
                {
                    UILabel recordIdInfoCellContent = new UILabel();
    
                    return recordIdInfoCellContent;
                }
                else
                {
                    return base.CreateCellContent(cellType, cellContentType, row);
                }
            }
    
            protected override object GetCellContentType(GridCellType cellType, GridRow row)
            {
                if (cellType == GridCellType.Cell)
                {
                    return typeof(UILabel);
                }
                else
                {
                    return base.GetCellContentType(cellType, row);
                }
            }
    
            public override string GetCellText(GridCellType cellType, GridRow row)
            {
                if (cellType == GridCellType.Cell)
                {
                    ProgressScheduleRowViewModel rowViewModel = row.DataItem as ProgressScheduleRowViewModel;
    
                    return rowViewModel.InfoCells[0].Value;
                }
                else
                {
                    return base.GetCellText(cellType, row);
                }
            }
    
            public override object GetCellValue(GridCellType cellType, GridRow row)
            {
                if (cellType == GridCellType.Cell)
                {
                    ProgressScheduleRowViewModel rowViewModel = row.DataItem as ProgressScheduleRowViewModel;
    
                    return rowViewModel.RowRecordId;
                }
                else
                {
                    return base.GetCellValue(cellType, row);
                }
            }
    
            protected override void PrepareCell(GridCellType cellType, GridRow row, GridCellView cell)
            {
                if (cellType == GridCellType.Cell)
                {
                    cell.Padding = new UIEdgeInsets(_space, _space, _space, _space);
    
                    UILabel recordIdInfoCellContent = cell.Content as UILabel;
    
                    recordIdInfoCellContent.TextAlignment = UITextAlignment.Left;
                }
                else
                {
                    base.PrepareCell(cellType, row, cell);
                }
            }
        }
    
    

    How does the filtering of the rows happen?

  • Posted 25 June 2018, 2:41 am EST

    Also noticed that FilterExpresion of the FlexGrid is always null.

  • Posted 28 June 2018, 7:07 am EST

    The filtering is done in the FlexGrid’s CollectionView which is what you’re basically creating when you set the ItemsSource. I don’t have any problem here with full text filtering in the default sample or by modifying the custom cells sample with full text filtering.

    A working sample would be helpful since your case is relatively complicated, and it’s not exactly clear to me what your app looks like from this code since it’s referring to Lists of other view models in the ItemsSource. That’s probably part of the issue too as a CollectionView is a key value association between data. What value are you trying to Filter against exactly?

Need extra support?

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

Learn More

Forum Channels