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

Fixed Table Layout - Column Width

2 Answers 290 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 16 Sep 2009, 07:19 PM
Hello,

I have a grid which I have configured with a Fixed Table Layout.
There are some cells which contain data which expand beyond the width of the grid and are thereby truncated as is expected.

The grid uses a Web User Control for an edit form.
When in edit mode the edit form displays properly, but the row that pertains to the data to be edited contains the columns with large amounts of data spilling over to the the adjacent cells.

I have been able to duplicate this behavior using one of your demos: UserControlEditForm simply by updating the following code:

<MasterTableView Width="100%" CommandItemDisplay="Top" TableLayout="Fixed" DataKeyNames="EmployeeID">

 


Is there anyway to apply the truncated behavior to the column data for the row being edited when in edit mode?

Thanks,
Jon

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 17 Sep 2009, 10:47 AM
Hi Jon,

From what I understood so far the problem that you face is when a Grid row is set in edit mode, the Grid cell with large data is spilling over to the adjacent cell. One suggestion will be to truncate the cell text if it exceeds a limit in code behind when the Grid row is in edit mode. Here is the sample code. Give it a try and see if this is what you require.

CS:
 
  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditFormItem editform = (GridEditFormItem)e.Item; 
            GridDataItem parentItem = (GridDataItem)editform.ParentItem; 
            if (parentItem["columnUniqueName"].Text.Length > 15) 
            { 
                parentItem["columnUniqueName"].Text = parentItem["columnUniqueName"].Text.Remove(15); 
            } 
            
        } 
       
   } 


Regards
Shinu
0
Jon
Top achievements
Rank 1
answered on 17 Sep 2009, 02:01 PM
Shinu,

This solution worked well.
I had to make a slight modification: I was getting a null reference error when the grid was in insert mode.
So, I added some code to do the truncation only in edit mode:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)    
    {    
            if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))    
            {    
                if (!e.Item.OwnerTableView.IsItemInserted)  
                {  
                  
                    GridEditFormItem editform = (GridEditFormItem)e.Item;    
                    GridDataItem parentItem = (GridDataItem)editform.ParentItem;    
                    if (parentItem["columnUniqueName"].Text.Length > 15)    
                    {    
                        parentItem["columnUniqueName"].Text = parentItem["columnUniqueName"].Text.Remove(15);    
                    }  
               
                }    
            }  
   }    
 


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