We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Hidden Column Values

Hello,

 

I need to access the data in a hidden column in the RowDataBound event.  I am using the following on page load complete to hide the Column:

GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("MATERIAL_ID")

 

I was using the code below to get the column ID, but it stopped working once the column was hidden:

GridGroupingControl1.TableDescriptor.Columns.GetColumnDescriptor("MATERIAL_ID").GetRelativeColumnIndex()

 

So now I am getting the hidden column index through different means (it happens to be column 15 in this example).

I am using the following line to get the cell text:

e.Row.Cells(15).Text

This works well for visible columns, but fails on the hidden column.

 

My goal is to use a hidden column to store row specific data.  I need to both populate it, and use it's values in the RowDataBound event but need it to remain hidden at all times.  I don't want to use JavaScript, or any hacks to make this work.  I am actually somewhat surprised that there isn't a property like 'Hidden='True'' for GridGroupingControl columns.

 

Visual Studio 2010

.NET Framework 4.0

Essential Studio 10.4.0.71

VB.Net Code behind

 

Thanks!

 

--Dale


5 Replies

RD Rakesh D Syncfusion Team February 4, 2013 12:09 PM UTC

Hi Dale,

 

Thank you for your interest in Syncfusion products.

 

Query : Hidden columns value in RowDataBound event.

 

We would like to let you know that when a column is removed from VisibleColumns collection you cannot retrieve the hidden column text value using e.Row.Cells[index].Text. It only contains the cell values of visible columns. We suggest you to use e.Row.Record.GetValue("ColumnName") to retrieve the value of hidden column and use it as per your requirement in RowDataBound event. Please refer below code snippet for further details.

 

[ aspx.cs ]

void GridGroupingControl1_RowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e)

        {

                for (int i = 0; i < e.Row.Cells.Count; i++)

                {

                    if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)

                    {

                        //Check if the name of the column

                        if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "City")

                        {

           //EmployeeID is a Hidden Column

                            if ((int)e.Row.Record.GetValue("EmployeeID") % 2 == 0)

                                e.Row.Cells[i].BackColor = System.Drawing.Color.Red;

                        }

                    }

          }}

 

For your convenience we have prepared a sample for the above scenario and it is attached below. Please refer to it.

Sample :

 

Please let us know if you have any concerns.

 

Regards,

Rakesh D



Hidden Column Value_a436f18b.zip


DN Dale Norhern February 5, 2013 06:31 PM UTC

Thank you!  That did work.  Are there any other limitations with hidden columns?  Do you know of any other methods that might could be used for both hidden and visible columns?

Thanks!

--Dale



RD Rakesh D Syncfusion Team February 7, 2013 06:40 PM UTC

Hi Dale,

 

Thank you for your interest in Syncfusion products.

 

Query : Any other methods that might could be used for both hidden and visible columns?

 

In order to use same method for both hidden and visible column we suggest you to hide the required column from grid by using “HideColumn” method in client side. Please refer below code snippet for further details.

 

function PageLoad() {

        var gridTable = GetEGridTable($get('<%=GridGroupingControl1.ClientID%>'));

        gridTable.HideColumn(0); //here 0 - column index which you want to hide

    }

 

For your convenience we have modified the sample for the above scenario and it is attached below. Please refer to it.

 

Please let us know if you have any concerns.

 

Regards,

Rakesh D

 



Hidden Column_c7eb77e7.zip


SA Sadagopan July 7, 2013 11:00 PM UTC

Hi - Is there a way I can view the values of a hidden column on client side selection? 

My hide column code is below

   $(function () {
                var gridTable = GetEGridTable($get('<%= GridGroupingControl1.ClientID %>'));
                gridTable.HideColumn(0);

            });

GridGroupingControl has this call,  ClientSideOnRecordClick="ShowSelectedRows(this)"

And I am trying to retreive the value of the column that I hid above, as such

 function ShowSelectedRows(gridObj) 
                                                            {             
                 document.getElementById("lblpostingid").innerText = gridObj.Row.GetValue('Postingid');
                                                            }

where 'Postingid' is the column that I hid.

Thanks
Al


AR Ajith R Syncfusion Team July 8, 2013 12:13 PM UTC

Hi Sadagopan, 

Thanks for your interest in Syncfusion products. 

We have created a sample to your requirement in the incident ID #110415. Could you please follow up the incident.  

Could you please use that sample and get back to us if you have any queries.

Let us know if you have any concerns. 

Regards,

Ajith R

 


Loader.
Live Chat Icon For mobile
Up arrow icon