title: Ways to set a minimum width on a Radgrid column with an empty width
body: <p>I have a RadGrid that has columns programatically added to it during PageLoad. For my webpage, there will always be at least one column with an empty width (HeaderStyle.Width = Unit.Empty), with the rest of the columns using specific pixel widths. All columns are resizable. (In my app, we are retrieving and saving these widths in the database) The grid is scrollable, so if they extend past the limits of the grid, the user can scroll without the grid itself being resized.</p>
  
  <p>The problem I'm having is that when the user resizes the browser window, at a certain width the blank column(s) will eventually get reduced to 0 width (as they are taking up the "leftover" space. Is there any approach that will allow me to limit this auto-resizing to 100px, so that the column is guaranteed to be visible?</p>
  
  <p>At least one column has to be of null OR percentage width, or else the RadGrid will default all columns to a percentage width, thus nullifying my specific pixel width designations.</p>
  
  <p>An approach I've tried is to add a blank column that fills in the rest of the space, as it wouldn't matter if it was 0 width. However, this causes problems when resizing the other columns. In this case, the blank column should be "consumed" until it is zero width, and then start extending the grid size (or add a scroll bar in this case). Instead, it simply gets pushed to the side, maintaining its width. I don't know if this approach is feasible or not, but I've left it in the code, simple uncomment it to play around with it.</p>
  
  <p>Here's my code:</p>
  
  <p>ASPX:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AA_TEST.aspx.cs" Inherits="Records.AA_TEST" %&gt;
  
  
  &lt;body id="body" runat="server"&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;telerik:RadScriptManager ID="RadScriptManager1" runat="server" /&gt;   
          &lt;telerik:RadGrid ID="RecordGrid" runat="server" Width="99%" BorderWidth="1px" AutoGenerateColumns="false"
              AllowPaging="true" AllowCustomPaging="true" PageSize="20" AllowSorting="true" AllowFilteringByColumn="false"
              HeaderStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Top"
              ItemStyle-HorizontalAlign="Left" AlternatingItemStyle-HorizontalAlign="Left"
              ItemStyle-VerticalAlign="Top" AlternatingItemStyle-VerticalAlign="Top"
              OnNeedDataSource="RecordGrid_NeedDataSource" OnItemDataBound="RecordGrid_ItemDataBound" &gt;
              &lt;PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" Position="Bottom" /&gt;
              &lt;MasterTableView AutoGenerateColumns="false" CommandItemDisplay="None" TableLayout="Fixed"
                  EnableHeaderContextMenu="false" AllowCustomSorting="true" AllowMultiColumnSorting="true"
                  Width="100%"&gt;
              &lt;/MasterTableView&gt;
              &lt;ClientSettings AllowColumnsReorder="True" ColumnsReorderMethod="Reorder" ReorderColumnsOnClient="True" ClientMessages-DragToGroupOrReorder=""&gt;
                  &lt;ClientEvents OnColumnResized="columnResized" /&gt;
                  &lt;Resizing EnableRealTimeResize="true" AllowColumnResize="true" ClipCellContentOnResize="true" ResizeGridOnColumnResize="true"/&gt;
                  &lt;Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" /&gt;
              &lt;/ClientSettings&gt;
              &lt;SortingSettings SortToolTip="" SortedAscToolTip="" SortedDescToolTip="" /&gt;
              &lt;GroupingSettings CaseSensitive="false" /&gt;
          &lt;/telerik:RadGrid&gt;
  
          &lt;telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /&gt;
          &lt;telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" &gt;
              &lt;AjaxSettings&gt;
                  &lt;telerik:AjaxSetting AjaxControlID="RecordGrid"&gt;
                      &lt;UpdatedControls&gt;
                          &lt;telerik:AjaxUpdatedControl ControlID="RecordGrid" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelRenderMode="Inline" /&gt;
                      &lt;/UpdatedControls&gt;
                  &lt;/telerik:AjaxSetting&gt;
              &lt;/AjaxSettings&gt;
          &lt;/telerik:RadAjaxManager&gt;
  
          &lt;telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"&gt;
          &lt;script type="text/javascript"&gt;
              //&lt;![CDATA[
              function columnResized(sender, eventArgs) {
                  var masterTableView = sender.get_masterTableView();
                  var uniqueName = eventArgs.get_gridColumn().get_uniqueName();
                  if (!(uniqueName == "DeleteButton")) {
                      var deleteColumn = masterTableView.getColumnByUniqueName("DeleteButton");
                      if (deleteColumn != null) {
                          var deleteColumnIndex = deleteColumn.get_element().cellIndex;
                          deleteColumn.set_resizable(true);
                          masterTableView.resizeColumn(deleteColumnIndex, 30);
                          deleteColumn.set_resizable(false);
                      }
                  }
              }
              //]]&gt;
          &lt;/script&gt;
          &lt;/telerik:RadScriptBlock&gt;  
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>ASPX.CS:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  using Telerik.Web.UI;
  
  namespace Records
  {
      public partial class AA_TEST : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              InitRecordGrid();
          }
  
          protected void InitRecordGrid()
          {
              if (!IsPostBack)
              {
                  GridBoundColumn firstNameColumn = new GridBoundColumn();
                  firstNameColumn.UniqueName = "FirstName";
                  firstNameColumn.DataField = "FirstName";
                  firstNameColumn.DataType = typeof(System.String);
                  firstNameColumn.HeaderText = "First Name";
                  firstNameColumn.Resizable = true;
                  firstNameColumn.Reorderable = true;
                  firstNameColumn.HeaderStyle.Width = Unit.Pixel(250);
                  RecordGrid.Columns.Add(firstNameColumn);
  
                  GridBoundColumn lastNameColumn = new GridBoundColumn();
                  lastNameColumn.UniqueName = "LastName";
                  lastNameColumn.DataField = "LastName";
                  lastNameColumn.DataType = typeof(System.String);
                  lastNameColumn.HeaderText = "Last Name";
                  lastNameColumn.Resizable = true;
                  lastNameColumn.Reorderable = true;
                  lastNameColumn.HeaderStyle.Width = Unit.Empty;
                  //lastNameColumn.HeaderStyle.Width = Unit.Pixel(250);
                  RecordGrid.Columns.Add(lastNameColumn);
  
                  /*
                  GridButtonColumn blankColumn = new GridButtonColumn();
                  blankColumn.UniqueName = "blank";
                  blankColumn.Resizable = false;
                  blankColumn.Reorderable = false;
                  blankColumn.HeaderStyle.Width = Unit.Empty;
                  RecordGrid.Columns.Add(blankColumn);
                  */
  
                  GridButtonColumn deleteColumn = new GridButtonColumn();
                  deleteColumn.UniqueName = "DeleteButton";
                  deleteColumn.HeaderStyle.Width = Unit.Pixel(30);
                  deleteColumn.ButtonType = GridButtonColumnType.ImageButton;
                  deleteColumn.ImageUrl = "/images/Delete.gif";
                  deleteColumn.ItemStyle.CssClass = "delete";
                  deleteColumn.CommandName = "Delete";
                  deleteColumn.Resizable = false;
                  deleteColumn.Reorderable = false;
                  RecordGrid.Columns.Add(deleteColumn);
              }
          }
  
          protected void RecordGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
          {
              List&lt;NameRow&gt; nameRows = new List&lt;NameRow&gt;();
  
              // Filler data
              nameRows.Add(new NameRow("Tyrion", "Lannister"));
              nameRows.Add(new NameRow("Jaime", "Lannister"));
              nameRows.Add(new NameRow("Daenerys", "Targeryen"));
              nameRows.Add(new NameRow("Jon", "Snow"));
              nameRows.Add(new NameRow("Robb", "Stark"));
              nameRows.Add(new NameRow("Benjamin", "Stark"));
              nameRows.Add(new NameRow("Khal", "Drogo"));
  
              RecordGrid.DataSource = nameRows;
          }
  
          protected void RecordGrid_ItemDataBound(object sender, GridItemEventArgs e)
          {
              if (e.Item is GridDataItem)
              {
                  GridDataItem item = e.Item as GridDataItem;
                  NameRow user = item.DataItem as NameRow;
  
                  item["FirstName"].Text = user.FirstName;
                  item["LastName"].Text = user.LastName;
              }
          }
  
          public class NameRow
          {
              public string FirstName = "";
              public string LastName = "";
  
              public NameRow(string first, string last)
              {
                  FirstName = first;
                  LastName = last;
              }
          }
      }
  }
  </code></pre>