This is a migrated thread and some comments may be shown as answers.

Get Cell Element in Custom Cell

9 Answers 997 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bao
Top achievements
Rank 1
Bao asked on 30 Aug 2017, 06:30 AM

Hi all,

I am using GridViewRelation with Custom Cell:

Now when i loop rows i can not get cell element in gridview:

foreach(var row in gridview.rows)

{

     var cell = gvLaborGuide.TableElement.GetCellElement(row, column);

}

9 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Aug 2017, 11:11 AM
Hello Bao, 

Thank you for writing.  

Following the provided information, I was unable to reproduce the issue you are facing. The custom cell element can be accessed as expected. I have attached my sample project. Am I missing something? Could you please specify the exact steps how to reproduce the problem?  Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess
Progress Telerik
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.
0
Bao
Top achievements
Rank 1
answered on 30 Aug 2017, 11:57 AM

Thank Dess,

I find out my problem. i think i can not get cell element when the hierarchical gridview is collapsed. Right now, when i load the hierarchical gridview like this :

Parent A

     Child B (it is collapsed at the loading time)

     Child C  (it is collapsed at the loading time)

so i can not get cell element child B. Is it right ?

https://www.screencast.com/t/hCxAsQyC // when it is loaded

https://www.screencast.com/t/cwNH9sDNb // when i expand item

Am i right ?

Thank.

 

0
Bao
Top achievements
Rank 1
answered on 30 Aug 2017, 12:06 PM

And one thing, it looks like i can not get cell element by this in hierarchical gridview:

  CustomCell= gvLaborGuide.TableElement.GetCellElement(gridview.Rows[1], gvLaborGuide.Columns["Low"]) as CustomCell;
                if (CustomCell!= null)
                {
                    CustomCell.IsVisibile = true;
                }

0
Bao
Top achievements
Rank 1
answered on 30 Aug 2017, 12:34 PM

I already tried this : http://www.telerik.com/forums/programmatically-setting-custom-control-cell-values-in-hierarchical-child-rows

When i tried to change value of the gridcolumn . It works. But with custom cell, i can not get value when i do:

 row.Cells[5].Value = "test";

 protected override void SetContentCore(object value)
        {

            // value is null
            base.SetContentCore(value);

This is the image: https://www.screencast.com/t/6SktH9Uq

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 31 Aug 2017, 01:16 PM
Hello Bao, 

Thank you for writing back. 

Due to the UI virtualization in RadGridView, cell elements are created only for currently visible cells and are being reused during operations like scrolling, filtering, grouping and so on. That is why until you expand the hierarchy, the respective cell elements won't be created.

The RadGridView.TableElement property holds the respective element for the MasterTemplate. It seems that you access a row by the RadGridView.Rows collection from the parent level. If you need to get the custom cell's value for a child cell it is necessary to extract it from the row's ChildRows collection. I have attached a sample project for your reference.

I hope this information helps.

Regards,
Dess
Progress Telerik
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.
0
Bao
Top achievements
Rank 1
answered on 04 Sep 2017, 04:08 PM

Hi Dess,

Thank for your help. In your code: 

  foreach (var childRow in row.ChildRows)
                {
                    customCell = radGridView1.TableElement.GetCellElement(childRow, this.radGridView1.Columns["Progress column"]) as ProgressBarCellElement;
                    if (customCell != null)
                    {
                        Console.WriteLine("Child "+customCell.Value);
                    }
                }

It never runs. It means the child can not be touched. How can i get the child when it is collapsed and set the value by click the button in your example ? 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Sep 2017, 06:00 AM
Hello Bao, 

Thank you for writing back. 

Note that due to the UI virtualization in RadGridView, cell elements are created only for currently visible cells and are being reused during operations like scrolling, filtering, grouping and so on. Hence, if you have a hierarchy, the cell elements for it will be created when you expand a certain parent row. Otherwise, you won't have cell elements for the hierarchy at all.

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
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.
0
Bao
Top achievements
Rank 1
answered on 06 Sep 2017, 05:05 AM

Hi Dess, I modify your example with checkbox in custom cell. And when i check the checkbox in child . It is not working correctly.

code: https://www.dropbox.com/s/n0soim6e11etj5w/hierarchicalGridView_CheckboxCustomCell.7z?dl=0

https://www.screencast.com/t/IhQ0VCnJ

Please help me . Thank Dess.

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Sep 2017, 10:32 AM
Hello Bao, 

Thank you for writing back. 

The provided video and sample project are greatly appreciated. Due to the UI virtualization in RadGridView, cell elements are created only for currently visible cells and are being reused during operations like scrolling, filtering, grouping and so on. The illustrated problem can be reproduced in a flat grid when you shrink the grid to enable the scrollbars and try scrolling the rows. You can refer to the other thread that you have opened on the same topic where the provided project from 5 Sept shows how to deal with this problem.

I would kindly ask you to use our support ticketing systems in future where you can attach projects and provide any detailed information. Moreover, threads are handled by Telerik support according to license and time of posting.

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
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.
Tags
GridView
Asked by
Bao
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Bao
Top achievements
Rank 1
Share this question
or