I have got an 'Invalid argument' javascript error when resizing the grid columns. Getting into javascript debugging, the error is pointed to the following line:
this.ColGroup.Cols[i].width=this.HeaderRow.cells[i].scrollWidth+"px";
I believe the error is caused by making a previously hidden column visible by a command like:
RadGrid.Columns.FindByUniqueName("Name").Display = true;
Could you please find out how to fix or get around this problem? Otherwise I will have to turn off the resizing in this mode.
Thanks.
12 Answers, 1 is accepted

Just wanted to say that we are having exactly the same issue as described in this thread. The user can show or hide any columns and save their own custom layouts. The first thing we do when loading the grid is set the visibility of certain columns.
Any news on a fix / work around?
Thanks in advance,
Steve.
Unfortunately I could not reproduce this issue. I created a test project in my attempt to recreate the abnormality you explained. I used the latest official build of RadControls and attached my sample web site project to this support thread. Please examine it and tell me if I am missing something.
You can review this online demo targeting the Client API of the grid.
If the problem still persists, I will suggest you open a regular support ticket and attach to it a working test project which reproduces the problem. Thus I will do my best to provide more to-the-point answer/solution.
Best regards,
Georgi Krustev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

Yes this is still causing us a problem. To be more precise it's happening when you hide columns in code behind such as the following:
'bind to a simple data source
Me.RadGrid1.DataSource = Me.VirtualDataSource
'loop round each column and look for certain column to hide (used to save/load/reload default grid layouts)
For Each column As Telerik.Web.UI.GridColumn In Me.RadGrid1.Columns
If column.UniqueName = "Col3" Then
'set the display of the row to false
column.Display =
False 'this is the line that causes javascript error!
Else
column.Display =
True
End If
Next
I'll do as you suggested and raise a ticket and include a sample project.
Many thanks,
Steve
I have answered you in the support ticket opened on this matter. The answer was as follows:
Hello Stephen,
Thank you for contacting us.
To avoid the depicted issue, you need to use Visible property to hide the column. If you hide the column with the Display property, the column is rendered and it is hidden. Hence even that the column is hidden it is used when the width of the resized column is calculated, which is incorrectly. Here is a code snippet showing how to accomplish this task:
'loop round each column and look for certain column to hide (used to save/load/reload default grid layouts) |
For Each column As Telerik.Web.UI.GridColumn In Me.RadGrid1.Columns |
If column.UniqueName = "Col3" Then |
'set the display of the row to false |
column.Visible = False |
End If |
Next |
Please give a try and let me know if other questions arise.
If you do not mind we will continue the communication in the started support thread on this issue in order to avoid duplicate discussions. In this way you will be in touch how the resolution of the problem goes.
Sincerely yours,
Georgi Krustev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

One more thing I noticed - the use of the 'Display' or 'Visible' property is fine when you make the change during a normal postback. But when you try to change the property value and update the grid using an ajax panel, the problem appears.

Unfortunately setting the 'Visible' property to false on a column means that the column wouldn't be available in the context menu where you choose to hide and show columns. The reason for using the 'Display' property was so the user can show the column within the grid and select the columns they wish to display. Then they can save their own custom layouts and this will then be reloaded whenever they go to that page. This all works fine so I don't want to use the 'Visible' property.
Many Thanks,
Steve.
There is another workaround for this behavior. To achieve your goal you can populate a hidden field with column indices corresponding to the columns which you need to hide. Hence on the client-side when the OnGridCreated event is raised you can use the client API and save the corresponding to the column index in the hidden field. Thus the columns are still rendered and the resizing will work well.
To accomplish this task you can use these Javascript methods:
function ShowColumn() |
{ |
var masterTableView = $find("<%= RadGrid1.ClientID%>").get_masterTableView(); |
masterTableView.showColumn(2) |
} |
function HideColumn() |
{ |
var masterTableView = $find("<%= RadGrid1.ClientID%>").get_masterTableView(); |
masterTableView.hideColumn(2) |
} |
For further information you can refer to this link.
Best regards,
Georgi Krustev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

Can you provide more information on how to make the work around work?
Can you provide a bit more information on your scenario?
Did you tried last suggestion of my colleague Georgi whether it is making sense in your scenario?
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

If I programmatically change the Column DISPLAY attribute from *True to *False, then resizing throws a java script error when the user drags a column to change a column size. I do not want to use the property VISIBLE as I want the users to be able to optionally add some of the less used columns to a grid.
Thanks
Steve

I have just tested the described scenario with latest version of RadControl for ASP.NET AJAX and couldn't reproduce the behaviour.
Please find the attached applicaiton and give it a try.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.