Flexgrid NET6

Posted by: kisar on 26 January 2023, 2:57 am EST

  • Posted 26 January 2023, 2:57 am EST

    Hi,

    im migrating my applivation from framework to net7

    hi have now your last library and i noticed that

    many things has changed from my version in the flexgrid component

    so i start asking my first question :


    1. BINDING:

      <c1:Column Width="60"  Binding="{Binding krecord_base.kid}">
                                   <c1:Column.HeaderTemplate>
                                       <DataTemplate>
                                           <TextBlock Text="{Binding kbinding_language.kgrid_col_id}" Style="{x:Static Kisar_lib_app_wpf:KAppResources.kcontrol__listview__header_text__style}"/>
                                       </DataTemplate>
                                   </c1:Column.HeaderTemplate>
                               </c1:Column>

    this is code as i used to bind the previous flexgrid,

    the flexgrid is connected through the viewmodel

    now i saw that for the main binding i can write directly : <c1:Column Width=“60” Binding=“krecord_base.kid”>

    but i did not find solution for the header binding and the header style


    1. SORTED COLUMN

      i did not find equivalend of “SortedColumn” event

      in my version i used to solve a problem :

      if i had that 3^ row selected and the user sort a column

      after the sorting the previous row does not remain selected

      but (very danger) it is selected the 3^ row in the new order

      I dont know if exists anymore the problem, but is there a manner to have a SortedColumn" event?

    3 BOUNDPROPERTYNAME

    i did not find any way to do this :

    FLEXGRID.Columns[nCol].BoundPropertyName

    4 BINDING SPEED

    the flexgrid is connected through the viewmodel

    if i use in the itemsource always connected it works very slow in case of many rows :

    viewmodel search:

    var array=getData();
    	        foreach (var item in array)
                    	this.kbinding_grid__itemssource.Add(new TRecord_search(item));


    100’000 records > 28 sec

    if i act in the wpf form

    FLEXGRID.ItemsSource=null;
    		viewmodel.search()
    		FLEXGRID.ItemsSource=viewmodel.kbinding_grid__itemssource;


    100’000 records > 7 sec

    So, i know that this is a general problem and not specifically of the flexgrid

    but in the framework i found a component ObservableCollectionEx that solved the problem,

    now with NET6 version of flexgrid it throw exception of index out of range…

    I would ask you if the flexgrid has some solution for this problem

    Thank you

    BS

  • Posted 28 January 2023, 5:21 am EST

    Hi,

    Thanks for reaching out to us with your query.

    1. C1Flexgrid Framework and Net6 Flexgrid have different architechtures. FlexGrid Net6 uses GridColumnHeaderCell to create a ColumnHeader content. To achieve your requirement, you can override BindCellContent of GridCellFactory.
    public override void BindCellContent(GridCellType cellType, GridCellRange range, FrameworkElement cellContent)
    {
        base.BindCellContent(cellType, range, cellContent);
        if (cellType == GridCellType.ColumnHeader & range.Column == 0)
        {
            var s = cellContent;
            Binding binding = new Binding("HeaderText");
            cellContent.SetBinding(GridColumnHeaderCell.TitleProperty, binding);
        }
    }
    1. We have raised an enhancement to the development team to support Sorted event.[Internal tracking Id - C1XAML-31061]

    2. You can use Binding property for the same.

    FLEXGRID.Columns[nCol].Binding
    1. We are unable to replicate this issue at our end. Could you please provide a small sample. So, that we can investigate and assist you accordingly.

    Please refer the sample: DynamicBinding.zip

    Best Regards,

    Nitin

  • Posted 29 January 2023, 3:45 am EST

    ABOUT 1.

    thank you, i understand now how i can bind the header text,

    but if i want to bind a template xaml? is it possible?

    is it possible to customize also the cell content with a xaml template?

    however in my opinion this new solution is not very convenient,

    because it forces me to work on two different levels, xaml and code,

    while before the flexgrid could only be managed by xaml.

    Is there any option for the future?

    ABOUT 4.

    i attached a very simple example,

    on the left side ther’s the flexgrid itemssource alwais connected while searching,

    on the right side ther’s the flexgrid itemssource disconnected-search-connected,

    how you can see ther’s a big difference.

    It would be very usefull to have a way to tell to the flexgrid through binding

    • suspend UI
    • refresh UI

    WpfApp1.zip

  • Posted 29 January 2023, 11:47 pm EST - Updated 30 January 2023, 10:19 pm EST

    Hi,

    1. FlexGrid Net6 uses GridColumnHeaderCell to render the ColumnHeaders. The template is already applied to it. Also, updating HeaderColumn Binding through CodeBehind is the only way.

    4 We have replicated this issue at our end. We have escalated it to the development team. Will inform you once we have any update from them.[Internal Tracking Id - C1XAML-31082]

    Regards,

    Nitin

  • Posted 30 January 2023, 10:38 pm EST

    Hi,

    1. FlexGrid delegates sorting to data-collection, therefore there is no api in FlexGrid, but it can be used the data-collection api.(see code snippet)
     grid.DataCollection.AttachSortChanged(OnSort);
    
     private void OnSort(object? sender, EventArgs e)
     {
         Debug.WriteLine("Sort Fires");
     }

    Please refer the attached sample for full implementation: FlexGridSort.zip

    Best Regards,

    Nitin

  • Posted 19 April 2023, 7:42 pm EST

    Hi,

    1. As per the development team, This is something expected since the grid receives 100,000 notifications from the collection and needs to update every time.

    The simplest solution is to look for an ObservableCollection supporting AddRange or implement one like below.

    public class MyObservableCollection<T> : ObservableCollection<T>
    {
        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            if (!_addingRange)
                base.OnCollectionChanged(e);
        }
    
        private bool _addingRange;
    
        public void AddRange(IEnumerable<T> newItems)
        {
            int startingIndex = Count;
            var newItemsList = newItems.ToList();
            try
            {
                _addingRange = true;
                foreach (T item in newItemsList)
                {
                    Add(item);
                }
            }
            finally { _addingRange = false; }
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, (System.Collections.IList)newItemsList, startingIndex));
        }
    }

    And then change search1 to use the AddRange method:

    public void search1()
    {
        this.binding_itemssource1.Clear();
        this.binding_itemssource1.AddRange(Enumerable.Range(0, 100000).Select(i => new TRecord(i + 1)));
    }

    Please refer the attached sample for the same: FlexGridData_Mod.zip

    Best Regards,

    Nitin

Need extra support?

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

Learn More

Forum Channels