Search

Jun 8, 2009

Best way to hiding Telerik Grid Column

Hi All, I was just looking into list of function while applying some logic for show/hide column of Telerik it provides two methods to do so.

public GridColumn FindByUniqueName(string UniqueName);
public GridColumn FindByUniqueNameSafe(string UniqueName);


As name suggest first method is not safe, it can throw GridExceptions if no column is found, where second one is returning null if no column is found. Along with these tow method, it have one property name UniqueName; this property helps FindByUniqueName and FindByUniqueNameSafe to find the column. So now we don’t need to remember the column id also we can now easily change the sequence of column as they are not referring with unique name.

<telerik:GridTemplateColumn UniqueName="Clients" HeaderText="Clients">


And server side write following code.

GridColumn gridColumn = dgTest.Columns.FindByUniqueNameSafe("Clients");
if (gridColumn != null)
gridColumn.Visible = false;

3 comments:

KeepingItSimple said...

Thank you. This was helpful.

Anonymous said...

I am generating the columns dynamically. So, I am not able to find out which column/cell user click on. And I need to send the header text information to the database.


for example, if the columns are col1, col2, col3. the data is in row1 is 1,2,3 and the data in row2 is 4,5,6.


If user clicks on 2 on row1, I need a text col2. How can I do that

Kavitha Rani said...


telerik show hide columns
telerik show hide columns(Click Here)