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.
Syncfusion Feedback

Function getVisibleColumnNames undefined

Thread ID:

Created:

Updated:

Platform:

Replies:

117221 Sep 9,2014 10:15 PM UTC Sep 15,2014 12:23 PM UTC ASP.NET Web Forms 5
loading
Tags: Grid
Roimer Machacón Otero
Asked On September 9, 2014 10:15 PM UTC

Hi, We are using the grid control. We need to hide a column in a grid for some cases. Now viewing in this link:

http://asp.syncfusion.com/demos/web/Grid/ShowHideColumn.aspx 

and creating the function this not work.

<script type="text/javascript">
        function ocultarColumna() {
            var grilla = $("#<%= gvsDetalle.ClientID%>").data("ejGrid");            
            //var grilla = $("#gvsDetalle").data("ejGrid");
            if (grilla.getVisibleColumnNames().length > 1) {
                grilla.hideColumns(9);
            }
        }
 </script>

The error is marked in getVisibleColumnNames as undefined.

Attach image with the error. Exist another form in code behind for can hide a column in a grid control?


Attachment: function_undefined_10afc4f3.rar

Ragavee U S [Syncfusion]
Replied On September 10, 2014 08:43 AM UTC

Hi Nestor Alvarado Namen

 

We have analyzed the issue that you have mentioned and suspect the cause of the issue is that the grilla is null and thus the method grilla.getVisibleColumnNames() is undefined.

 

We also found that from your code snippet that the to obtain the gridObj, Control.ClientID Property is used.

 

The ClientID value is generated by concatenating the ID values of each parent naming container with the ID value of the control. In data-binding scenarios where multiple instances of a control are rendered, an incrementing value is inserted in front of the control's ID value. Each segment is separated by an underscore character (_)

 

In our grid, in order to obtain the grid data, we need to use the ID of the Grid. So please use the Control.ID property or specify the id of the grid directly in order to obtain the grid data. Please refer the below code snippet.

 

<script type="text/javascript">

        function ocultarColumna() {

            var grilla = $("#<%= gvsDetalle.ID%>").data("ejGrid");

            //var grilla = $("#gvsDetalle").data("ejGrid");

            if (grilla.getVisibleColumnNames().length > 1) {

                grilla.hideColumns(9);

            }

        }

</script>

 

Please let us know if you need any further assistance.

 

Regards

Ragavee U S


Roimer Machacón Otero
Replied On September 11, 2014 03:44 PM UTC

Hi. We're testing the example sent for you and this not work. We are using the function javascript by code behind through "ScriptManager.RegisterStartupScript" because depending of a number obtain in code behind

Ragavee U S [Syncfusion]
Replied On September 12, 2014 12:52 PM UTC

Hi Nestor Alvarado Namen

 

We have analyzed your requirement and we need few clarifications on the scenario that you prefer to achieve.

 

Can you please provide us more information on the scenario in which you prefer to use "ScriptManager.RegisterStartupScript" in your sample?

 

The provided information will be helpful for us to analyze your requirement further and provide you response accordingly as early as possible.

 

Please let us know if you have any queries.

 

Regards

Ragavee U S


Roimer Machacón Otero
Replied On September 12, 2014 02:32 PM UTC

Hi.

Us in the page load have this code:

Dim parametro = CInt(implementacion.traerParametro("pasan"))
If Session("tipoplan") <>  parametro Then
    ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "01", "ocultarColumna();", True)
End If

Now depending of the value that have the variable "parametro" call to the javasript function ocultarColumna using the ScriptManager

Ragavee U S [Syncfusion]
Replied On September 15, 2014 12:23 PM UTC

Hi Nestor Alvarado Namen

 

Based on the information that you have provided, we found that you would like to hide a column depending on the value of the “parametro” variable.

 

Since the grid will be rendered/generated only at the end of the pageLoad function, the grid Object will be null in the ocultarColumna() method. And thus the grilla.getVisibleColumnNames() is undefined.

 

So we suggest you to hide the required columns from the server side itself as in the code snippet below.

 

Dim parametro = CInt(implementacion.traerParametro("pasan"))

            If Session("tipoplan") <> parametro Then

                Me.OrdersGrid.Columns(9).Visible = False

           End If

 

Please try the above snippet in your sample project and get back to us if you have any further queries.

 

Regards

Ragavee U S


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.

Warning Icon 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.Close Icon

;