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.
Unfortunately, activation email could not send to your email. Please try again.

Hidden Column Values

Thread ID:

Created:

Updated:

Platform:

Replies:

106919 Jan 31,2013 02:18 PM Jul 8,2013 08:13 AM ASP.NET Web Forms (Classic) 5
loading
Tags: GridGroupingControl
Dale Norhern
Asked On January 31, 2013 02:18 PM

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


Rakesh D [Syncfusion]
Replied On February 4, 2013 07:09 AM

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

Dale Norhern
Replied On February 5, 2013 01:31 PM

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


Rakesh D [Syncfusion]
Replied On February 7, 2013 01:40 PM

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

Sadagopan
Replied On July 7, 2013 07:00 PM

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

Ajith R [Syncfusion]
Replied On July 8, 2013 08:13 AM

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

 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;