cancel
Showing results for 
Search instead for 
Did you mean: 

How to find a Syncfusion Grid column name for the selected cell?

Highlighted
Occasional Contributor

How to find a Syncfusion Grid column name for the selected cell?

Hi,

 

My use case is to match the columnName:columnValue passed to my script to the actual runtime values.

 

Now if i am on a cell having rowIndex=5 and colIndex=6 , how can i find the columnName corresponding to current colIndex?

 

I have a Syncfusion grid.

 

Thanks

Thanks,
D
1 REPLY 1
Highlighted
Community Hero

Re: How to find a Syncfusion Grid column name for the selected cell?

This is a Delphi SyncFusion grid right?

 

In which case, there are two possibilities.

 

You car try getting the display name, which is stored in (C# Script notation):

 

<Grid_Object>["Columns"](Column_Number)["DisplayLabel"]

 

 

But that may not always be populated. If it's not, it will come back empty. In that case, you need to look through the underlying dataset object as the displayname will inherited from that.

 

To get that, you need the field value name from the grid column:

 

<Grid_Object>["Columns"](Column_Number)["FieldName"]

 

 

Which will give you a field name. You then need to iterate through the fields in the recordset looking for a field name which matches the above value. When you hit a match, get the displayname of that field.

 

To get the column field name:

 

<Grid_Object>["Columns"](Column_Number)["FieldName"]

 

 

and number of fields in the dataset (there may be hidden ones - you can't rely on the on-screen visible count):

 

<Grid_Object>["DataLink"]["DataSet"]["FieldList"]["Count"]

 

 

and use this number to iterate through the dataset fields/columns:

 

 

 

 

<Grid_Object>["DataLink"]["DataSource"]["DataSet"]["Fields"]["Fields"](Field_Number)["DisplayName"]

 

 

Which should match the on screen column name.

 

Which one works will vary depending on your developers. In the Delphi app I'm working on, I have to use a mixture of both as it's not consistent. So I check the grid display label first. If it's blank, I drop into a secondary routine which looks for a match with the field name.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors