CreateCellElement Event not fired on all cells displayed

15 posts, 0 answers
  1. Amand
    Amand avatar
    23 posts
    Member since:
    Aug 2012

    Posted 20 Dec 2016 Link to this post

    Hello,

    I try to use custom cells dynamically following data I want to display ( use checkbox when data is boolean). To do so I use CreateCellElement to instantiate my custom cell but it appears to this event is not fired on that specific column and the column have default display with "True" and "False" instead of check boxes. 

     

    Here is a part of my code :

    this._radVirtualGrid1.CreateCellElement += onGridCellTypeNeeded;
     
     
    private void onGridCellTypeNeeded(object sender, VirtualGridCreateCellEventArgs e)
            {
                if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
                {
                    DataType type = myDataDescriptor.getDataType(e.ColumnIndex);
                    switch (type )
                    {
                        case DataType.Bool:
                            e.CellElement = new CheckBoxCellElement(e.ColumnIndex);
                            registerCustomColumnIfNeeded(e.ColumnIndex);                      
                            break;
                    }
                }
            }

    Do you know how to fix it ?

    Regards,

    Amand.

  2. Amand
    Amand avatar
    23 posts
    Member since:
    Aug 2012

    Posted 20 Dec 2016 in reply to Amand Link to this post

    Update :

    This problem does not appears if column are the first displayed ( 1st to 9~10th) but when the column is like the 20th. If so there is still a chance that the event is fired with this specific index ( about 20% chance).

    Regards,

    Amand.

  3. Amand
    Amand avatar
    23 posts
    Member since:
    Aug 2012

    Posted 20 Dec 2016 Link to this post

    Hello again,

    I found the problem, the method RegisterCustomColumn has to be called during the grid initialization. It might force the event to be fired for these specific columns.

    Regards,

    Amand.

  4. Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 21 Dec 2016 Link to this post

    Hi Amand,

    Thank you for writing.

    Indeed, when creating custom cells one needs to also register them by calling the RegisterCustomColumn method. Additional information and an example are available here: RadVirtualGrid | Creating Custom Cells.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Amand
    Amand avatar
    23 posts
    Member since:
    Aug 2012

    Posted 23 Dec 2016 in reply to Hristo Link to this post

    Hello,

    I was wondering if there is a way to invalidate custom columns in order to refresh it (e.g. I have custom column 3 and I want after an user event to unregister column 3 and register column 4) because for now I have to scroll out and scroll in in order to have the  changed display taken in account.

    Regards,

    Amand.

  6. Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 23 Dec 2016 Link to this post

    Hello Amand,

    Thank you for writing back.

    If by refreshing you mean triggering the CellValueNeeded event to fill data you can do it by calling the SynchronizeRows method of the table element: 
    this.radVirtualGrid1.TableElement.SynchronizeRows(true, true);

    If you want to update the layout you can call the InvalidateMeasure method again by accessing the table element and pass a true flag.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Padre
    Padre avatar
    7 posts
    Member since:
    Dec 2016

    Posted 26 Dec 2016 Link to this post

    Hello. Need help.

    I have one virtual grid for two data sources.For first data source created custom cell. If set second data source in grid, then custom cell for first data source do not reload. Event CreateCellElement did not called with this column index.

  8. Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 27 Dec 2016 Link to this post

    Hi Padre,

    Thank you for writing.

    Data in RadVirtualGrid is populated in the CellValueNeeded event. If I understand correctly your scenario at some point you are handling the event differently to populate different data. In this respect, it would not be necessary to create the custom cell again. You can refresh the data by calling the SynchronizeRows method as per my previous reply.

    The CreateCellElement is being raised during the initialization of the control or when you scroll because of the virtualization. In case you need additional assistance please open up a support ticket and send us a small sample as per your local setup.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  9. Padre
    Padre avatar
    7 posts
    Member since:
    Dec 2016

    Posted 27 Dec 2016 in reply to Hristo Link to this post

    Hi Hristo.

    This doesn't work. I have the following event handler on a button click

            private void OpenComponentList(ComponentLineType _type)
            {
                currentType = _type;

                editComponentTable  = GetEditCoponents(_type);//DataTable

                switch(_type)
                {
                    case ComponentLineType.Bom:
                        EditComponentsGrid.MasterViewInfo.RegisterCustomColumn(2);
                        this.EditComponentsGrid.ColumnCount = 3;
                        break;
                    case ComponentLineType.Add:
                        this.EditComponentsGrid.ColumnCount = 4;
                        break;
                }                        
                EditComponentsGrid.RowCount = editComponentTable.Rows.Count;
                if (EditComponentsGrid.RowCount == 0) 
                    EditComponentsGrid.RowCount = 1;
                EditComponentsGrid.BestFitColumns();
                EditComponentsGrid.TableElement.SynchronizeRows(true, true);
            }

    Event hendler for CreateCellElement
            private void CreateCellElement(object sender, VirtualGridCreateCellEventArgs e)
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                    return;
                if (currentType == ComponentLineType.Bom)
                {
                    if (e.ColumnIndex == 2)
                    {
                        CheckBoxCellElement CellElement = new CheckBoxCellElement();
                        e.CellElement = CellElement;
                    }
                }
            }

     

    Check box -is child control for cell element. May be hid him for ComponentLineType.Bom?

  10. Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 28 Dec 2016 Link to this post

    Hello Padre,

    Thank you for writing.

    Currently, RadVirtualGrid does not allow removing of its custom columns. We have an issue logged in our feedback portal. I have also added a vote for it on your behalf. Additionally, you can subscribe to the item and be updated with all of its status changes here: FIX. RadVirtualGrid - once a custom column is added it cannot be removed from the grid. 

    The issue can be worked around by manually removing the registered custom column. In order to immediately reflect the changes in the grid you would also need to trigger a layout update of the virtualized row element. I am sending you attached a sample project demonstrating the suggested approach.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  11. Padre
    Padre avatar
    7 posts
    Member since:
    Dec 2016

    Posted 29 Dec 2016 in reply to Hristo Link to this post

    Thank you.
    I solved this problem using CellFormatting handler. 
    private void VirtualGrid_CellFormatting(object sender, VirtualGridCellElementEventArgs e)
    {
                if (VirtualGrid.MasterViewInfo.IsCustomColumn(e.CellElement.ColumnIndex))
                {
                    RadElementCollection a = e.CellElement.Children;
                    RadCheckBoxElement cb = a[0] as RadCheckBoxElement;
                    if (cb != null)
                        cb.Visibility = (currentState == State.State1) ? ElementVisibility.Visible : ElementVisibility.Hidden;
                }
    }

  12. Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 29 Dec 2016 Link to this post

    Hi Padre,

    Thank you for writing.

    I am glad that you have managed to achieve a satisfying result. Please note, however, that the custom cell will not be removed this way.

    I hope this helps. Please let me know if you need further questions.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  13. Padre
    Padre avatar
    7 posts
    Member since:
    Dec 2016

    Posted 29 Dec 2016 in reply to Hristo Link to this post

    Hi Htisto.

    I will write when i find problems.

    thank you for help.

     

  14. Amand
    Amand avatar
    23 posts
    Member since:
    Aug 2012

    Posted 02 Jan Link to this post

    Hi Hristo,

    Thank you and Padre, the workaround on the feedback portal works perfectly for my problem. Now all my columns can be Hide/Show :)

    For those who want the code snap write that every time you want to refresh your display after hiding a column:

    foreach (VirtualGridRowElement rowElement in    this.radVirtualGrid1.VirtualGridElement.TableElement.GetDescendants(delegate(RadElement x) { return x is VirtualGridRowElement; }, TreeTraversalMode.BreadthFirst)){  rowElement.CellContainer.Children.Clear();}

    Regards,

    Amand.

  15. Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 02 Jan Link to this post

    Hi Amand,

    Thank you for writing.

    I am glad that it is also working well in your project. Clearing the elements in the cell container object ultimately triggers the CreateCellElement which will allow full recreation of the cells for all columns.

    I hope this helps. Please let me know if you need further assistance.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top