Dynamically created columns causes problem when column Display = False
We are Telerik v2010 Q1. When add a column with Dispay = false it hides the column, but there is the a large gap to the right of the grid e.g.
Before
ID |
Col 2 |
Col 3 |
|
|
|
After
Col 2 |
Col 3 |
<< GAP?! >> |
|
|
|
Extract
//id column
col = new GridBoundColumn();
//TODO: Setting col.Display = false causes a problem
this.uxResults.Columns.Add(col);
//now ammend properties
col.UniqueName = “ID"
col.Visible = true; //NB Note that Display is set to false!!
col.DataField = “ID”
col.HeaderText = "";
col.FilterListOptions = GridFilterListOptions.VaryByDataType;
//col.AllowFiltering = true;
//col.AllowSorting = true;
//col.ReadOnly = true;
col.Display = false;
7 Answers, 1 is accepted
I followed your description in the attached sample, however I was not able to replicate the problem. Can you check it out and let me know what differs in your case?
Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I can confirm that your example has worked...so I have tried to recreate my code as best I can in your example, but I still can't replicate the issue.
I know this is an almost impossible question to answer without being able to see my code, but have you any ideas where I could start to look for this problem. Steps I have tried so far are:-
1. Turned off all grid events (except request NeedDataSource)
2. The grid doens't add the columns on Page_Load (I know that this has caused problems elsewhere) as there is a method that needs to be called to set various paramters. I have tried to code around this to see if this could be the cause and as far as I can tell it is not.
Thanks,
Stuart
this.uxResults.Columns.Add(col);
ClientSettings Scrolling-UseStaticHeaders="true"
MasterTableView TableLayout="Fixed"
Scrolling AllowScroll="True"
If either of these are on e.g. True of Fixed then it puts the gap in?
PS Lenny_shp thanks for your suggestion....but sadly that didn't work.
I have included the HTML below (Note uxGrid is just inherited from the RadGrid).
<cc1:uxGrid runat="server" ID="uxResults" AutoGenerateColumns="False" GridLines="None" |
Height="93%" BorderWidth="0px" AllowSorting="True" Style="outline: none" ShowGroupPanel="False" |
EnableHeaderContextMenu="True" AllowPaging="True" ShowFooter="True" Width="100%" PageSize="25" |
OnRowDrop="uxResults_RowDrop" |
OnInsertCommand="uxResults_InsertCommand" |
OnUpdateCommand="uxResults_UpdateCommand" |
OnItemCreated="uxResults_ItemCreated" |
OnItemDataBound="uxResults_ItemDataBound" |
OnNeedDataSource="uxResults_NeedDataSource" |
OnColumnCreated="uxResults_ColumnCreated"> |
<HeaderStyle HorizontalAlign="Left" /> |
<ItemStyle HorizontalAlign="Left" /> |
<AlternatingItemStyle HorizontalAlign="Left" /> |
<%--<ClientSettings Scrolling-AllowScroll="True" Scrolling-UseStaticHeaders="true" Selecting-AllowRowSelect="true"--%> |
<ClientSettings Scrolling-AllowScroll="True" Selecting-AllowRowSelect="true" |
EnablePostBackOnRowClick="false" AllowDragToGroup="true" EnableRowHoverStyle="true" |
AllowRowsDragDrop="True"> |
<Selecting AllowRowSelect="True" /> |
<ClientEvents OnRowSelected="onGridRowSelected" /> |
<%--<Scrolling AllowScroll="True" UseStaticHeaders="True" />--%> |
<Scrolling AllowScroll="True" /> |
</ClientSettings> |
<MasterTableView GroupLoadMode="Client" EditMode="InPlace" CommandItemDisplay="Top"> |
<%--<MasterTableView TableLayout="Fixed" GroupLoadMode="Client" EditMode="InPlace" CommandItemDisplay="Top">--%> |
<%--Direct Edit section--%> |
<EditFormSettings ColumnNumber="2" CaptionDataField="Name" CaptionFormatString="Edit details for {0}"> |
<FormTableItemStyle Wrap="False"></FormTableItemStyle> |
<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> |
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" |
Width="100%" /> |
<FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> |
<FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> |
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> |
<EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" |
UniqueName="EditCommandColumn1" CancelText="Cancel edit"> |
</EditColumn> |
<%--<FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>--%> |
<FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle> |
</EditFormSettings> |
<%-- --%> |
<CommandItemSettings ShowExportToWordButton="false" ShowExportToExcelButton="true" |
ShowExportToCsvButton="true" ShowExportToPdfButton="true" /> |
</MasterTableView> |
<PagerStyle AlwaysVisible="True" Mode="NextPrevAndNumeric"></PagerStyle> |
<SortingSettings SortedBackColor="#C5D9F1"></SortingSettings> |
</cc1:uxGrid> |
I used the additional information provided in the modified sample attached to this post however I am still unable to observe the undesired behavior.
Therefore it would be great if you can post the code for creating the columns here and specify on which event you are adding them to the grid's columns collection. Also any additional information on when the problem occurs, e.g. on initial load or after particular actions, and in which browser you see it, might help in finding the source of the issue.
Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thanks for your help with the issue. The grid in on a usercontrol which is dynamically added to the main page on the click of a button..the columns are being created on a Bind() method. Now I know from other posts that they should be created OnLoad, but I did try this and the outcome was the same - although due to the relative complexity it is difficult to isolate. The browser is IE 8, and the problem occurs everytime the grid is loaded.
I have managed to work around this issue, by use some server code to get the ID and then using RegisterStatupScript to dynamically generate the required Java code required, but I would still like to know what is causing the issue incase there is an unlying problem with my code.
Thanks,
Stuart
Could you please open a formal suggort ticket and send me a sample project of you scenario and faced issue?
However I followed your last instruction, I am still unable to replicate it. Please see attached the modified sample.
Greetings,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.