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

Index of column

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 29 Mar 2016, 01:26 PM

Does the IndexOf() method from GridColumnCollection return a zero based index? 

What will be returned if the column wasn´t found?

Thanks,

Frank

 

Remark to: http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/columns/reordering

...

GridColumnCollection cols = grid.MasterTableView.Columns;

GridColumn c = cols.FindByUniqueName(columnName);

if (c != null)

...

 

FindByUniqueName throws a GridException if the column wasn´t found.

So why testing c for null?

 

 

...

 

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 30 Mar 2016, 12:40 PM
Hello Frank,

The GridColumnCollection is a zero-based collection. Thus, the first item in the collection will have 0 as index.

Thank you for noting that the FindByUniqueName() method will throw an exception if the column is not found. In order to avoid the exception you can use the FindByUniqueNameSafe() method.

Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Frank
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or