This is a migrated thread and some comments may be shown as answers.

RadGrid headerContextMenu and resizing

4 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Farjana
Top achievements
Rank 1
Farjana asked on 06 Feb 2014, 05:01 AM
Hi,

I have a rad Grid in my page with "EnableHeaderContextMenu" set to true as well as "AllowColumnResize" set to true.
<Resizing ResizeGridOnColumnResize="false" AllowResizeToFit="true" AllowColumnResize="true"/>.
Prob:
When i remove some columns using headercontextmenu, the grid is getting resized an d i can see a white space at the end of grid, until a postback happens.
I tried setting "AllowColumnResize" to false, then it works fine. But i want both columns to be either resized or removed using header context menu. In both the cases grid should not be resized.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Feb 2014, 06:06 AM
Hi Farjana,

Please try adding the following to your RadGrid and check if the issue exists.

ASPX:
<ClientSettings>
 <Resizing ResizeGridOnColumnResize="false" AllowResizeToFit="true" AllowColumnResize="true" />
 <ClientEvents OnColumnHidden="onColumnHidden" />
</ClientSettings>

JS:
<script type="text/javascript">
 function onColumnHidden(sender, args) {
   sender.get_masterTableView().get_element().style.tableLayout = "auto";
   sender.get_masterTableViewHeader().get_element().style.tableLayout = "auto";
    window.setTimeout(function () {
    sender.get_masterTableViewHeader().get_element().style.tableLayout = "fixed";
    sender.get_masterTableView().get_element().style.tableLayout = "fixed";
     }, 1)
   }
</script>

Thanks,
Princy
0
Farjana
Top achievements
Rank 1
answered on 06 Feb 2014, 07:20 AM
Thanks. It works fine:)
I am trying to change the display name of the columns, that appears when i click on "Columns" in header context menu. I coludn't find an option to change it. What should i do? See the attachment, I would like to assign "headertext" of the columns to header text menu columns
0
Princy
Top achievements
Rank 2
answered on 07 Feb 2014, 04:07 AM
Hi Farjana,

By default the HeaderContextMenu Columns get the name from the HeaderText property of the columns. Please find the attached image. Provide your full code snippet if this doesn't help.

ASPX:
<telerik:GridBoundColumn DataField="OrderID" HeaderText="Order*ID"></telerik:GridBoundColumn>
<telerik:GridHyperLinkColumn DataTextField="ShipCountry" HeaderText="ShipCountry">
</telerik:GridHyperLinkColumn>
<telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipVia" HeaderText="ShipVia"></telerik:GridBoundColumn>

Thanks,
Princy

0
Farjana
Top achievements
Rank 1
answered on 07 Feb 2014, 06:13 AM
Hi Princy,

Thanks, it works fine. I was using the below item to change the header text(dynamic columns). It has just modified the item text and not the actual header text.
So, it was not reflecting in the HeaderContextMenu
headerItem[column.UniqueName].Controls[0]).Text = "ID";
On explicitly assigning, column.HeaderText ="ID"., it works fine.

Thanks,
Farjana
Tags
Grid
Asked by
Farjana
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Farjana
Top achievements
Rank 1
Share this question
or