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

[Solved] Wrap and dynamic created columns

12 Answers 239 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andreas Kaech
Top achievements
Rank 1
Andreas Kaech asked on 28 May 2008, 11:35 AM
Hi,
my grid has TableLayout="Fixed" and the columns are dynamically created.
Now I have a strange behaviour when setting in one Column (in the ItemCreated Handler):
gridItem["Column"].wrap=false
When the width of this Column is not set, the column does'nt wrap (as expected).
But when I set the width of this Column, wrap=false is ignored.
What to do?

Thanks for answering,
Andreas

12 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 May 2008, 12:28 PM
Hi,

Try setting TableLayout to Fixed and see whether it is working or not.  You can also have a look at the following help article.
No wrap for grid cell content

Princy.
0
Andreas Kaech
Top achievements
Rank 1
answered on 28 May 2008, 02:09 PM
Hi Princy,
Thanks for pointing at this help article. This approach works, but now  I miss the nice little points (...) at the end of the line ;-)
My TableLayout is "Fixed" - I wonder, why there is another behaviour, when setting a width to this column.

Regards,
Andreas
0
Andreas Kaech
Top achievements
Rank 1
answered on 29 May 2008, 10:27 AM
Supplement:
OK, the nice little points (...) appear now at the end of the cell (you know, there are a lot of parameters to set ;-), but in Firefox, the hidden text spans over the other columns (very ugly...).
Is there any parameter I've forgotten to set?

Regards,
Andreas
0
Sebastian
Telerik team
answered on 30 May 2008, 07:24 AM
Hello Andreas,

Unfortunately cell content clipping is supported under IE browser only (Gecko-based browsers do not have such type of browser functionality).

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andreas Kaech
Top achievements
Rank 1
answered on 30 May 2008, 08:27 AM
Hello Stephen,
Ok, but RadGrid has a property <ItemStyle Wrap="false" /> - with no effect (?)
How to implement this property successful?

Regards,
Andreas
0
Daniel
Telerik team
answered on 30 May 2008, 03:08 PM
Hi Andreas Kaech,

For your convenience I have prepared a demo application to show you how to achieve your goal.

It would be really helpful if you don't declaratively add the following line.
<ItemStyle Wrap="false" /> 
This will prevent you from changing the Wrap ItemStyle from code-behind.

Nevertheless, if you prefer to set it this way and you need more assistance please take a look at the example attached to this message.

Greetings,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andreas Kaech
Top achievements
Rank 1
answered on 30 May 2008, 03:36 PM
Hi Daniel,
Thanks for this example. Now I know the issue:
You can't give the column a fixed width. So its not practicable for me.
I want to hide the text not suitable in the column-width an show the hole text in the tooltip.
There is no "workaround" to get this effect (working on Firefox too)?

Greetings,
Andreas
0
Shinu
Top achievements
Rank 2
answered on 02 Jun 2008, 06:21 AM
Hi,

Go through the following link.
Adding tooltips for grid items

Shinu.
0
Daniel
Telerik team
answered on 02 Jun 2008, 12:22 PM
Hello Andreas,

Please add the following code declaratively:
<ClientSettings> 
    <Resizing AllowColumnResize="true" /> 
    <Resizing ClipCellContentOnResize="true" /> 
</ClientSettings> 

You will also need to set TableLayout=fixed and Wrap=false.
Additionally, DataFormatString="<nobr>{0}</nobr>" or string.Format("<nobr>{0}</nobr>", ...) must be used in order to make this possible.

Please check the sample web site I made for your convenience. Both clipping and tooltips are realized into the attached demo project.

Best wishes,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andreas Kaech
Top achievements
Rank 1
answered on 02 Jun 2008, 03:20 PM
Hi Daniel,
your example does the trick! Thanks.
There is still a problem in my rather complex application:
I bind the data in RadGrid1_NeedDataSource. Is this the reason, why I get in the GridTableCell Text-property only "&nbsp;"?
I get the content of the cell via
gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["Uniquename"].ToString().
I hope, you can give me a hint without sending my complex example.

Regards,
Andreas

0
Daniel
Telerik team
answered on 04 Jun 2008, 11:34 AM
Hello Andreas,

To get the cell content (text) you may use the following code:

GridItemType[] types = new GridItemType[] { GridItemType.AlternatingItem, GridItemType.Item }; 
GridItem[] items = RadGrid1.MasterTableView.GetItems(types);             
foreach (GridItem gitem in items) 
    Response.Write(((GridDataItem)gitem)["myColumn"].Text + "<br />"); 
 

The above mentioned example will give you all cells within the myColumn column.

Alternatively, you can get a single cell with index=2 and column name="myColumn" this way:
GridItem[] gitems = RadGrid1.MasterTableView.GetItems(new GridItemType[]{ GridItemType.Item, GridItemType.AlternatingItem }); 
Response.Write(((GridDataItem)gitems[2])["myColumn"].Text + "<br />"); 
 

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andreas Kaech
Top achievements
Rank 1
answered on 05 Jun 2008, 12:13 PM
Hi Daniel,
thanks for helping me. I get now the cell-text.
But because string.Format("<nobr>{0}</nobr>",...) don't work with Firefox, I made a workaround, who works for me:
string.Format("<div style='overflow:hidden; width:100%'><nobr>{0}</nobr></div>",...)
The only "drawback" is the missing ellipse (...) at the end of the cell.

Regards,
Andreas
Tags
Grid
Asked by
Andreas Kaech
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Andreas Kaech
Top achievements
Rank 1
Sebastian
Telerik team
Daniel
Telerik team
Shinu
Top achievements
Rank 2
Share this question
or